diff --git a/.gitignore b/.gitignore index ede21726578..9c8c57d6d6c 100644 --- a/.gitignore +++ b/.gitignore @@ -154,6 +154,8 @@ packages/serverless-workflow-diagram-editor/**/src/main/webapp/WEB-INF/deploy/ packages/serverless-workflow-diagram-editor/**/src/main/webapp/WEB-INF/lib/ packages/serverless-workflow-diagram-editor/**/src/main/webapp/WEB-INF/model/ packages/serverless-workflow-diagram-editor/**/src/main/webapp/model/ +packages/serverless-workflow-diagram-editor/kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/resources/org/kie/workbench/common/stunner/client/lienzo/resources/ + # dashbuilder packages/dashbuilder/**/org.uberfire @@ -267,4 +269,4 @@ fabric.properties # xml-parser-ts-codegen on some packages packages/bpmn-marshaller/**/ts-gen packages/dmn-marshaller/**/ts-gen -packages/scesim-marshaller/**/ts-gen \ No newline at end of file +packages/scesim-marshaller/**/ts-gen diff --git a/packages/serverless-workflow-diagram-editor-envelope/src/api/ServerlessWorkflowDiagramEditorLanguageData.ts b/packages/serverless-workflow-diagram-editor-envelope/src/api/ServerlessWorkflowDiagramEditorLanguageData.ts index 24dec80daa7..fbce59065cf 100644 --- a/packages/serverless-workflow-diagram-editor-envelope/src/api/ServerlessWorkflowDiagramEditorLanguageData.ts +++ b/packages/serverless-workflow-diagram-editor-envelope/src/api/ServerlessWorkflowDiagramEditorLanguageData.ts @@ -26,13 +26,9 @@ export function getServerlessWorkflowLanguageData(resourcesPathPrefix: string): editorId: editors.swf.id, gwtModuleName: editors.swf.name, resources: [ - { - type: "css", - paths: [`${resourcesPathPrefix}/${editors.swf.name}/css/patternfly.min.css`], - }, { type: "js", - paths: [`${resourcesPathPrefix}/${editors.swf.name}/${editors.swf.name}.nocache.js`], + paths: [`${resourcesPathPrefix}/${editors.swf.name}/${editors.swf.name}.js`], }, ], }; diff --git a/packages/serverless-workflow-diagram-editor/.gitignore b/packages/serverless-workflow-diagram-editor/.gitignore index 336d144f4d3..f927086434f 100644 --- a/packages/serverless-workflow-diagram-editor/.gitignore +++ b/packages/serverless-workflow-diagram-editor/.gitignore @@ -2,3 +2,9 @@ lienzo-webapp/src/main/webapp/org.kie.lienzo.LienzoShowcase/ .idea sw-editor/sw-editor-kogito-app/src/main/webapp/org.kie.workbench.common.stunner.sw.KogitoSWEditor/ +kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/resources/org/kie/workbench/common/stunner/client/lienzo/resources/css/animate.min.css +kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/resources/org/kie/workbench/common/stunner/client/lienzo/resources/css/font-awesome.min.css +kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/resources/org/kie/workbench/common/stunner/client/lienzo/resources/css/patternfly-additions.min.css +kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/resources/org/kie/workbench/common/stunner/client/lienzo/resources/css/patternfly.min.css +kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/resources/org/kie/workbench/common/stunner/client/lienzo/resources/css/uberfire-patternfly.css +kie-wb-common-stunner/kie-wb-common-stunner-client/kie-wb-common-stunner-lienzo/src/main/resources/org/kie/workbench/common/stunner/client/lienzo/resources/js/ diff --git a/packages/serverless-workflow-diagram-editor/appformer-bom/pom.xml b/packages/serverless-workflow-diagram-editor/appformer-bom/pom.xml index 3495e2644e2..77d97f894f8 100644 --- a/packages/serverless-workflow-diagram-editor/appformer-bom/pom.xml +++ b/packages/serverless-workflow-diagram-editor/appformer-bom/pom.xml @@ -7,15 +7,15 @@ ~ 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. + ~ under the License. --> ${project.version} - - org.kie.kogito.stunner.serverless.editor - uberfire-workbench-processors - ${project.version} - - - - org.kie.kogito.stunner.serverless.editor - errai-cdi-client - ${project.version} - - javax.enterprise cdi-api @@ -298,33 +286,6 @@ - - - org.gwtproject - gwt-user - ${version.org.gwtproject} - - - - org.gwtproject - gwt-dev - ${version.org.gwtproject} - - - javax.servlet - javax.servlet-api - - - commons-logging - commons-logging - - - javax.annotation - javax.annotation-api - - - - com.google.jsinterop base @@ -490,6 +451,12 @@ ${project.version} + + org.kie.kogito.stunner.serverless.editor.third_party + errai + ${project.version} + + org.kie.kogito.stunner.serverless.editor.third_party.tooling.marshalling.json common @@ -531,56 +498,12 @@ ${project.version} - - org.kie.kogito.stunner.serverless.editor.third_party - stylesheets - ${project.version} - - org.kie.kogito.stunner.serverless.editor lienzo-tests ${project.version} - - com.jcraft - jsch - ${version.com.jcraft} - - - - - org.codehaus.groovy - groovy-all - indy - ${version.org.codehaus.groovy} - - - - - mysql - mysql-connector-java - ${version.org.mysql-driver} - test - - - - org.postgresql - postgresql - ${version.org.postgres-driver} - test - - - - org.mariadb.jdbc - mariadb-java-client - ${version.org.mariadb.jdbc} - test - - - @@ -618,6 +541,18 @@ test + + org.gwtproject + gwt-dev + 2.10.0 + + + + org.gwtproject + gwt-user + 2.10.0 + + junit junit diff --git a/packages/serverless-workflow-diagram-editor/appformer-client-api/pom.xml b/packages/serverless-workflow-diagram-editor/appformer-client-api/pom.xml index dd5dbe2f936..8be5194768b 100644 --- a/packages/serverless-workflow-diagram-editor/appformer-client-api/pom.xml +++ b/packages/serverless-workflow-diagram-editor/appformer-client-api/pom.xml @@ -7,15 +7,15 @@ ~ 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. + ~ under the License. --> - javax.enterprise - cdi-api + com.google.jsinterop + jsinterop-annotations - org.gwtproject - gwt-user + io.crysknife + crysknife-core diff --git a/packages/serverless-workflow-diagram-editor/appformer-client-api/src/main/java/org/appformer/client/context/DefaultEditorContextProviderImpl.java b/packages/serverless-workflow-diagram-editor/appformer-client-api/src/main/java/org/appformer/client/context/DefaultEditorContextProviderImpl.java index c0954e2d630..a3e26c429c9 100644 --- a/packages/serverless-workflow-diagram-editor/appformer-client-api/src/main/java/org/appformer/client/context/DefaultEditorContextProviderImpl.java +++ b/packages/serverless-workflow-diagram-editor/appformer-client-api/src/main/java/org/appformer/client/context/DefaultEditorContextProviderImpl.java @@ -6,15 +6,15 @@ * 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. + * under the License. */ @@ -22,7 +22,7 @@ import java.util.Optional; -import javax.enterprise.context.ApplicationScoped; +import jakarta.enterprise.context.ApplicationScoped; @ApplicationScoped public class DefaultEditorContextProviderImpl implements EditorContextProvider { diff --git a/packages/serverless-workflow-diagram-editor/appformer-client-api/src/main/java/org/appformer/client/stateControl/registry/impl/DefaultRegistryImpl.java b/packages/serverless-workflow-diagram-editor/appformer-client-api/src/main/java/org/appformer/client/stateControl/registry/impl/DefaultRegistryImpl.java index 2eae720c00a..a285cbd0d49 100644 --- a/packages/serverless-workflow-diagram-editor/appformer-client-api/src/main/java/org/appformer/client/stateControl/registry/impl/DefaultRegistryImpl.java +++ b/packages/serverless-workflow-diagram-editor/appformer-client-api/src/main/java/org/appformer/client/stateControl/registry/impl/DefaultRegistryImpl.java @@ -6,15 +6,15 @@ * 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. + * under the License. */ @@ -25,6 +25,7 @@ import java.util.Deque; import java.util.List; +import jakarta.enterprise.context.Dependent; import org.appformer.client.stateControl.registry.DefaultRegistry; import org.appformer.client.stateControl.registry.Registry; import org.appformer.client.stateControl.registry.RegistryChangeListener; @@ -35,6 +36,7 @@ * Note: The Stack class behavior when using the iterator is not the expected one, so used * ArrayDeque instead of an Stack to provide right iteration order. */ +@Dependent public class DefaultRegistryImpl implements DefaultRegistry { private final Deque items = new ArrayDeque<>(); diff --git a/packages/serverless-workflow-diagram-editor/appformer-client-api/src/main/resources/META-INF/ErraiApp.properties b/packages/serverless-workflow-diagram-editor/appformer-client-api/src/main/resources/META-INF/ErraiApp.properties deleted file mode 100644 index 1e4ae2bf9d8..00000000000 --- a/packages/serverless-workflow-diagram-editor/appformer-client-api/src/main/resources/META-INF/ErraiApp.properties +++ /dev/null @@ -1,33 +0,0 @@ -# -# 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. -# -# -# ErraiApp.properties -# -# Do not remove, even if empty! -# -# This is a marker file. When it is detected inside a JAR or at the -# top of any classpath, the subdirectories are scanned for deployable -# components. As such, all Errai application modules in a project -# should contain an ErraiApp.properties at the root of all classpaths -# that you wish to be scanned. -# -# There are also some configuration options that can be set in this -# file, although it is rarely necessary. See the documentation at -# https://docs.jboss.org/author/display/ERRAI/ErraiApp.properties -# for details. \ No newline at end of file diff --git a/packages/serverless-workflow-diagram-editor/appformer-client-api/src/main/resources/org/appformer/AppformerClientAPI.gwt.xml b/packages/serverless-workflow-diagram-editor/appformer-client-api/src/main/resources/org/appformer/AppformerClientAPI.gwt.xml deleted file mode 100644 index 699f27e7e9e..00000000000 --- a/packages/serverless-workflow-diagram-editor/appformer-client-api/src/main/resources/org/appformer/AppformerClientAPI.gwt.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - diff --git a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/pom.xml b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/pom.xml index 0dd424394b0..cfa481267ac 100644 --- a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/pom.xml +++ b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/pom.xml @@ -7,15 +7,15 @@ ~ 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. + ~ under the License. --> jar - - org.kie.kogito.stunner.serverless.editor - errai-ioc - provided - - - org.jboss.spec.javax.annotation - jboss-annotations-api_1.2_spec - - - - - javax.annotation - javax.annotation-api - com.google.elemental2 elemental2-dom - provided com.google.elemental2 elemental2-promise - provided com.google.jsinterop jsinterop-annotations - provided org.kie.kogito.stunner.serverless.editor - appformer-client-api - - - org.gwtproject - gwt-user + uberfire-api org.kie.kogito.stunner.serverless.editor - uberfire-api - provided + appformer-client-api diff --git a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/context/impl/KogitoEditorContextProviderImpl.java b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/context/impl/KogitoEditorContextProviderImpl.java index 6bf876089df..d1a30321b0f 100644 --- a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/context/impl/KogitoEditorContextProviderImpl.java +++ b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/context/impl/KogitoEditorContextProviderImpl.java @@ -6,15 +6,15 @@ * 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. + * under the License. */ @@ -22,9 +22,8 @@ import java.util.Optional; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Alternative; - +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Alternative; import org.appformer.client.context.Channel; import org.appformer.client.context.EditorContextProvider; import org.appformer.client.context.OperatingSystem; diff --git a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/context/interop/EditorContextWrapper.java b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/context/interop/EditorContextWrapper.java index 279998c3c0d..97f42abc378 100644 --- a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/context/interop/EditorContextWrapper.java +++ b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/context/interop/EditorContextWrapper.java @@ -6,40 +6,46 @@ * 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. + * under the License. */ package org.appformer.kogito.bridge.client.context.interop; +import jsinterop.annotations.JsPackage; import jsinterop.annotations.JsProperty; import jsinterop.annotations.JsType; /** - * - * Provide access to the editorContext object - * + * + * Provide access to the editorContext object + * */ -@JsType(isNative = true, namespace = "window", name = "envelope") +@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "envelope") public class EditorContextWrapper { - @JsProperty - public native String getChannel(); + @JsProperty(name = "editorContext") + public static native EditorContext get(); - @JsProperty - public native String getOperatingSystem(); - @JsProperty(name = "editorContext") - public static native EditorContextWrapper get(); + @JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "editorContext") + public static class EditorContext { + + @JsProperty + public native String getChannel(); + + @JsProperty + public native String getOperatingSystem(); - @JsProperty - public native boolean isReadOnly(); + @JsProperty + public native boolean isReadOnly(); + } } diff --git a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/diagramApi/DiagramApiInteropWrapper.java b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/diagramApi/DiagramApiInteropWrapper.java index 45e045545dd..eb2b5cda857 100644 --- a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/diagramApi/DiagramApiInteropWrapper.java +++ b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/diagramApi/DiagramApiInteropWrapper.java @@ -6,27 +6,28 @@ * 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. + * under the License. */ package org.appformer.kogito.bridge.client.diagramApi; +import jsinterop.annotations.JsPackage; import jsinterop.annotations.JsProperty; import jsinterop.annotations.JsType; /** * Javascript bridge to access actual DiagramApi available in the envelope namespace */ -@JsType(isNative = true, namespace = "window", name = "envelope") +@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "envelope") public class DiagramApiInteropWrapper { /** diff --git a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/diagramApi/DiagramApiServiceProducer.java b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/diagramApi/DiagramApiServiceProducer.java index f9a25cc2d5a..c894d1f2ea7 100644 --- a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/diagramApi/DiagramApiServiceProducer.java +++ b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/diagramApi/DiagramApiServiceProducer.java @@ -6,24 +6,23 @@ * 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. + * under the License. */ package org.appformer.kogito.bridge.client.diagramApi; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Produces; - import elemental2.dom.DomGlobal; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Produces; import org.appformer.kogito.bridge.client.interop.WindowRef; /** diff --git a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/i18n/I18nApiInteropWrapper.java b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/i18n/I18nApiInteropWrapper.java index eeaefce9589..bc8c2afd87a 100644 --- a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/i18n/I18nApiInteropWrapper.java +++ b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/i18n/I18nApiInteropWrapper.java @@ -6,15 +6,15 @@ * 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. + * under the License. */ @@ -22,10 +22,11 @@ import elemental2.promise.Promise; import jsinterop.annotations.JsMethod; +import jsinterop.annotations.JsPackage; import jsinterop.annotations.JsProperty; import jsinterop.annotations.JsType; -@JsType(isNative = true, namespace = "window", name = "envelope") +@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "envelope") public class I18nApiInteropWrapper { @JsMethod diff --git a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/i18n/I18nServiceProducer.java b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/i18n/I18nServiceProducer.java index ca649067341..1fb01f647a4 100644 --- a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/i18n/I18nServiceProducer.java +++ b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/i18n/I18nServiceProducer.java @@ -6,24 +6,23 @@ * 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. + * under the License. */ package org.appformer.kogito.bridge.client.i18n; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Produces; - import elemental2.dom.DomGlobal; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Produces; import org.appformer.kogito.bridge.client.interop.WindowRef; /** diff --git a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/keyboardshortcuts/KeyboardShortcutsApiInteropWrapper.java b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/keyboardshortcuts/KeyboardShortcutsApiInteropWrapper.java index 678b379c1bf..78349402a00 100644 --- a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/keyboardshortcuts/KeyboardShortcutsApiInteropWrapper.java +++ b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/keyboardshortcuts/KeyboardShortcutsApiInteropWrapper.java @@ -6,20 +6,21 @@ * 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. + * under the License. */ package org.appformer.kogito.bridge.client.keyboardshortcuts; +import jsinterop.annotations.JsPackage; import jsinterop.annotations.JsProperty; import jsinterop.annotations.JsType; import org.appformer.client.keyboardShortcuts.KeyboardShortcutsApiOpts; @@ -27,7 +28,7 @@ /** * Javascript bridge to access actual KeyboardShortcutsApi available in the envelope namespace */ -@JsType(isNative = true, namespace = "window", name = "envelope") +@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "envelope") public class KeyboardShortcutsApiInteropWrapper { public native int registerKeyPress(final String combination, diff --git a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/keyboardshortcuts/KeyboardShortcutsServiceProducer.java b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/keyboardshortcuts/KeyboardShortcutsServiceProducer.java index 9f3b7eb89de..cab4d69f2ff 100644 --- a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/keyboardshortcuts/KeyboardShortcutsServiceProducer.java +++ b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/keyboardshortcuts/KeyboardShortcutsServiceProducer.java @@ -6,24 +6,23 @@ * 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. + * under the License. */ package org.appformer.kogito.bridge.client.keyboardshortcuts; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Produces; - import elemental2.dom.DomGlobal; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Produces; import org.appformer.kogito.bridge.client.interop.WindowRef; /** diff --git a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/notifications/NotificationsApi.java b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/notifications/NotificationsApi.java index fb4a44b1e12..46947b6e381 100644 --- a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/notifications/NotificationsApi.java +++ b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/notifications/NotificationsApi.java @@ -6,15 +6,15 @@ * 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. + * under the License. */ @@ -22,6 +22,7 @@ import java.util.List; +import jsinterop.annotations.JsPackage; import jsinterop.annotations.JsType; import org.uberfire.workbench.model.bridge.Notification; import org.uberfire.workbench.model.bridge.NotificationSeverity; @@ -37,7 +38,7 @@ * Alerts supports severities {@link NotificationSeverity#INFO} and {@link NotificationSeverity#ERROR}. Any other * severity will be treated as INFO. */ -@JsType(isNative = true) +@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "envelope") public interface NotificationsApi { /** diff --git a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/notifications/NotificationsApiInteropWrapper.java b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/notifications/NotificationsApiInteropWrapper.java index b86198bc1a7..4930cd4debe 100644 --- a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/notifications/NotificationsApiInteropWrapper.java +++ b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/notifications/NotificationsApiInteropWrapper.java @@ -6,15 +6,15 @@ * 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. + * under the License. */ @@ -23,11 +23,12 @@ import java.util.List; import jsinterop.annotations.JsMethod; +import jsinterop.annotations.JsPackage; import jsinterop.annotations.JsProperty; import jsinterop.annotations.JsType; import org.uberfire.workbench.model.bridge.Notification; -@JsType(isNative = true, namespace = "window", name = "envelope") +@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "envelope") public class NotificationsApiInteropWrapper implements NotificationsApi { @JsMethod diff --git a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/notifications/NotificationsServiceProducer.java b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/notifications/NotificationsServiceProducer.java index eaddea24a87..2c2557678ab 100644 --- a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/notifications/NotificationsServiceProducer.java +++ b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/notifications/NotificationsServiceProducer.java @@ -6,24 +6,23 @@ * 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. + * under the License. */ package org.appformer.kogito.bridge.client.notifications; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Produces; - import elemental2.dom.DomGlobal; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Produces; import org.appformer.kogito.bridge.client.interop.WindowRef; public class NotificationsServiceProducer { diff --git a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/PMMLEditorMarshallerApi.java b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/PMMLEditorMarshallerApi.java deleted file mode 100644 index 9a28e8b9c2b..00000000000 --- a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/PMMLEditorMarshallerApi.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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 org.appformer.kogito.bridge.client.pmmleditor.marshaller; - -import org.appformer.kogito.bridge.client.pmmleditor.marshaller.model.PMMLDocumentData; - -/** - * API which interfaces with PMMLEditor Marshaller available into KIE Tools. - */ -public interface PMMLEditorMarshallerApi { - - /** - * Given a string containing the xmlContent, it returns a {@link PMMLDocumentData} JSInterop class, - * which holds all required data used by DMN Editor to manage a PMML file. - * @param xmlContent - * @return - */ - PMMLDocumentData getPMMLDocumentData(String xmlContent); - -} diff --git a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/PMMLEditorMarshallerApiInteropWrapper.java b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/PMMLEditorMarshallerApiInteropWrapper.java deleted file mode 100644 index 717f7094b2d..00000000000 --- a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/PMMLEditorMarshallerApiInteropWrapper.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 org.appformer.kogito.bridge.client.pmmleditor.marshaller; - -import jsinterop.annotations.JsMethod; -import jsinterop.annotations.JsProperty; -import jsinterop.annotations.JsType; -import org.appformer.kogito.bridge.client.pmmleditor.marshaller.model.PMMLDocumentData; - -/** - * Javascript bridge to access actual PMMLEditorMarshallerApi available in the envelope namespace - */ -@JsType(isNative = true, namespace = "window", name = "envelope") -public class PMMLEditorMarshallerApiInteropWrapper { - - @JsMethod - public native PMMLDocumentData getPMMLDocumentData(String xmlContent); - - @JsProperty(name = "pmmlEditorMarshallerService") - public static native PMMLEditorMarshallerApiInteropWrapper get(); - -} diff --git a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/PMMLEditorMarshallerService.java b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/PMMLEditorMarshallerService.java deleted file mode 100644 index 97e508f157a..00000000000 --- a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/PMMLEditorMarshallerService.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 org.appformer.kogito.bridge.client.pmmleditor.marshaller; - -import org.appformer.kogito.bridge.client.pmmleditor.marshaller.model.PMMLDocumentData; - -/** - * A {@link PMMLEditorMarshallerApi} implementation used when envelope API is available - */ -public class PMMLEditorMarshallerService implements PMMLEditorMarshallerApi { - - @Override - public PMMLDocumentData getPMMLDocumentData(String xmlContent) { - return getWrapper().getPMMLDocumentData(xmlContent); - } - - PMMLEditorMarshallerApiInteropWrapper getWrapper() { - return PMMLEditorMarshallerApiInteropWrapper.get(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/PMMLEditorMarshallerServiceProducer.java b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/PMMLEditorMarshallerServiceProducer.java deleted file mode 100644 index 834fdde7753..00000000000 --- a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/PMMLEditorMarshallerServiceProducer.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 org.appformer.kogito.bridge.client.pmmleditor.marshaller; - -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Produces; - -import elemental2.dom.DomGlobal; -import org.appformer.kogito.bridge.client.interop.WindowRef; - -/** - * Produces {@link PMMLEditorMarshallerService} beans according to whether the envelope API is available or not - */ -public class PMMLEditorMarshallerServiceProducer { - - @Produces - @ApplicationScoped - public PMMLEditorMarshallerApi produce() { - - if (isEnvelopeAvailable()) { - return new PMMLEditorMarshallerService(); - } - - DomGlobal.console.warn("[PMMLEditorMarshallerApi] Envelope API is not available. Empty PMML models will be passed"); - return new UnavailablePMMLEditorMarshallerService(); - } - - boolean isEnvelopeAvailable() { - return WindowRef.isEnvelopeAvailable(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/UnavailablePMMLEditorMarshallerService.java b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/UnavailablePMMLEditorMarshallerService.java deleted file mode 100644 index 518724661a3..00000000000 --- a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/UnavailablePMMLEditorMarshallerService.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 org.appformer.kogito.bridge.client.pmmleditor.marshaller; - -import org.appformer.kogito.bridge.client.pmmleditor.marshaller.model.PMMLDocumentData; - -/** - * This {@link PMMLEditorMarshallerApi} implementation is used when the envelope API is not available - */ -public class UnavailablePMMLEditorMarshallerService implements PMMLEditorMarshallerApi { - - @Override - public PMMLDocumentData getPMMLDocumentData(String xmlContent) { - return new PMMLDocumentData(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/model/JSIUtils.java b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/model/JSIUtils.java deleted file mode 100644 index 5602e2f660f..00000000000 --- a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/model/JSIUtils.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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 org.appformer.kogito.bridge.client.pmmleditor.marshaller.model; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -import jsinterop.base.Js; -import jsinterop.base.JsArrayLike; - -public class JSIUtils { - - private JSIUtils() { - // Utils class - } - - /** - * Helper method to create a new, empty JsArrayLike - * @return - */ - public static native JsArrayLike getNativeArray() /*-{ - return []; - }-*/; - - /** - * Returns a JsArrayLike where each element represents the unwrapped object (i.e. object.value) of the original one. - * It the original JsArrayLike is null, returns a new, empty one - * @param original - * @param - * @return - */ - public static native JsArrayLike getUnwrappedElementsArray(final JsArrayLike original) /*-{ - var toReturn = []; - if (original != null) { - toReturn = original.map(function (arrayItem) { - var retrieved = arrayItem.value - var toSet = retrieved == null ? arrayItem : retrieved - return toSet; - }); - } - return toReturn; - }-*/; - - public static List toList(final JsArrayLike jsArrayLike) { - final List toReturn = new ArrayList<>(); - if (Objects.nonNull(jsArrayLike)) { - for (int i = 0; (i < jsArrayLike.getLength()); i++) { - final D toAdd = Js.uncheckedCast(jsArrayLike.getAt(i)); - toReturn.add(toAdd); - } - } - return toReturn; - } - -} diff --git a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/model/PMMLDocumentData.java b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/model/PMMLDocumentData.java deleted file mode 100644 index f621127d389..00000000000 --- a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/model/PMMLDocumentData.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 org.appformer.kogito.bridge.client.pmmleditor.marshaller.model; - -import java.util.List; - -import jsinterop.annotations.JsOverlay; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsProperty; -import jsinterop.annotations.JsType; -import jsinterop.base.JsArrayLike; - -@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object") -public class PMMLDocumentData { - - @JsOverlay - public final List getModels() { - if (getNativeModels() == null) { - setNativeModels(JSIUtils.getNativeArray()); - } - return JSIUtils.toList(JSIUtils.getUnwrappedElementsArray(getNativeModels())); - } - - @JsProperty(name = "models") - public native JsArrayLike getNativeModels(); - - @JsProperty(name = "models") - public native void setNativeModels(JsArrayLike models); - -} diff --git a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/model/PMMLFieldData.java b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/model/PMMLFieldData.java deleted file mode 100644 index 08cacddb44e..00000000000 --- a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/model/PMMLFieldData.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 org.appformer.kogito.bridge.client.pmmleditor.marshaller.model; - -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsProperty; -import jsinterop.annotations.JsType; - -@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object") -public class PMMLFieldData { - - @JsProperty(name = "fieldName") - public native String getFieldName(); - - @JsProperty(name = "usageType") - public native String getUsageType(); -} diff --git a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/model/PMMLModelData.java b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/model/PMMLModelData.java deleted file mode 100644 index ee7101b0739..00000000000 --- a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/model/PMMLModelData.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 org.appformer.kogito.bridge.client.pmmleditor.marshaller.model; - -import java.util.List; - -import jsinterop.annotations.JsOverlay; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsProperty; -import jsinterop.annotations.JsType; -import jsinterop.base.JsArrayLike; - -@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object") -public class PMMLModelData { - - @JsOverlay - public final List getFields() { - if (getNativeFields() == null) { - setNativeFields(JSIUtils.getNativeArray()); - } - return JSIUtils.toList(JSIUtils.getUnwrappedElementsArray(getNativeFields())); - } - - @JsProperty(name = "modelName") - public native String getModelName(); - - @JsProperty(name = "fields") - public native JsArrayLike getNativeFields(); - - @JsProperty(name = "fields") - public native void setNativeFields(JsArrayLike models); - -} diff --git a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/resource/interop/ResourceContentEditorServiceWrapper.java b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/resource/interop/ResourceContentEditorServiceWrapper.java index 6d8f4d3b748..55712b9c55b 100644 --- a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/resource/interop/ResourceContentEditorServiceWrapper.java +++ b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/resource/interop/ResourceContentEditorServiceWrapper.java @@ -6,21 +6,22 @@ * 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. + * under the License. */ package org.appformer.kogito.bridge.client.resource.interop; import elemental2.promise.Promise; +import jsinterop.annotations.JsPackage; import jsinterop.annotations.JsProperty; import jsinterop.annotations.JsType; @@ -28,11 +29,11 @@ * Javascript bridge to access actual ResourceContentService available in the envelope namespace * */ -@JsType(isNative = true, namespace = "window", name = "envelope") +@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "envelope") public class ResourceContentEditorServiceWrapper { public native Promise get(String uri); - + public native Promise get(String uri, ResourceContentOptions options); public native Promise list(String pattern); diff --git a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/resource/producer/ResourceContentServiceProducer.java b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/resource/producer/ResourceContentServiceProducer.java index 7ecf208efd5..d2751615a18 100644 --- a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/resource/producer/ResourceContentServiceProducer.java +++ b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/resource/producer/ResourceContentServiceProducer.java @@ -6,24 +6,23 @@ * 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. + * under the License. */ package org.appformer.kogito.bridge.client.resource.producer; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Produces; - import elemental2.dom.DomGlobal; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Produces; import org.appformer.kogito.bridge.client.interop.WindowRef; import org.appformer.kogito.bridge.client.resource.ResourceContentService; import org.appformer.kogito.bridge.client.resource.impl.EnvelopeResourceContentService; diff --git a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/stateControl/interop/StateControl.java b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/stateControl/interop/StateControl.java index 52ec9a16391..d939335bc65 100644 --- a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/stateControl/interop/StateControl.java +++ b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/stateControl/interop/StateControl.java @@ -6,21 +6,22 @@ * 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. + * under the License. */ package org.appformer.kogito.bridge.client.stateControl.interop; import jsinterop.annotations.JsMethod; +import jsinterop.annotations.JsPackage; import jsinterop.annotations.JsProperty; import jsinterop.annotations.JsType; import org.appformer.kogito.bridge.client.stateControl.registry.interop.KogitoJSCommandRegistry; @@ -28,7 +29,7 @@ /** * Represents the TypeScript StateControl engine present on the Envelope */ -@JsType(isNative = true, namespace = "window", name = "gwt") +@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "gwt") public class StateControl { /** diff --git a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/stateControl/registry/interop/KogitoJSCommandRegistry.java b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/stateControl/registry/interop/KogitoJSCommandRegistry.java index 886f4b718bb..cfb3e8787b5 100644 --- a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/stateControl/registry/interop/KogitoJSCommandRegistry.java +++ b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/stateControl/registry/interop/KogitoJSCommandRegistry.java @@ -6,20 +6,21 @@ * 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. + * under the License. */ package org.appformer.kogito.bridge.client.stateControl.registry.interop; +import jsinterop.annotations.JsPackage; import jsinterop.annotations.JsType; import org.appformer.kogito.bridge.client.stateControl.interop.StateControlCommand; @@ -28,7 +29,7 @@ * * @param anything that can be considered a Command */ -@JsType(isNative = true) +@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object") public interface KogitoJSCommandRegistry { /** diff --git a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/stateControl/registry/producer/CommandRegistryProducer.java b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/stateControl/registry/producer/CommandRegistryProducer.java index b1c2fcec021..db63783d8c3 100644 --- a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/stateControl/registry/producer/CommandRegistryProducer.java +++ b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/stateControl/registry/producer/CommandRegistryProducer.java @@ -6,15 +6,15 @@ * 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. + * under the License. */ @@ -22,9 +22,8 @@ import java.util.function.Supplier; -import javax.enterprise.context.Dependent; -import javax.enterprise.inject.Produces; - +import jakarta.enterprise.context.Dependent; +import jakarta.enterprise.inject.Produces; import org.appformer.client.stateControl.registry.Registry; import org.appformer.client.stateControl.registry.impl.DefaultRegistryImpl; import org.appformer.kogito.bridge.client.interop.WindowRef; diff --git a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/workspace/interop/WorkspaceServiceWrapper.java b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/workspace/interop/WorkspaceServiceWrapper.java index 0674f09a5c8..1807185166a 100644 --- a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/workspace/interop/WorkspaceServiceWrapper.java +++ b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/workspace/interop/WorkspaceServiceWrapper.java @@ -6,21 +6,22 @@ * 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. + * under the License. */ package org.appformer.kogito.bridge.client.workspace.interop; import jsinterop.annotations.JsMethod; +import jsinterop.annotations.JsPackage; import jsinterop.annotations.JsProperty; import jsinterop.annotations.JsType; import org.appformer.kogito.bridge.client.workspace.WorkspaceService; @@ -28,7 +29,7 @@ /** * Javascript bridge to access the {@link WorkspaceService} available in the envelope namespace. */ -@JsType(isNative = true, namespace = "window", name = "envelope") +@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "envelope") public class WorkspaceServiceWrapper { @JsMethod diff --git a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/workspace/producer/WorkspaceServiceProducer.java b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/workspace/producer/WorkspaceServiceProducer.java index 0a437917a72..1b9e4741253 100644 --- a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/workspace/producer/WorkspaceServiceProducer.java +++ b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/java/org/appformer/kogito/bridge/client/workspace/producer/WorkspaceServiceProducer.java @@ -6,23 +6,22 @@ * 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. + * under the License. */ package org.appformer.kogito.bridge.client.workspace.producer; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Produces; - +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Produces; import org.appformer.kogito.bridge.client.interop.WindowRef; import org.appformer.kogito.bridge.client.workspace.WorkspaceService; import org.appformer.kogito.bridge.client.workspace.impl.DefaultWorkspaceServiceImpl; diff --git a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/resources/META-INF/ErraiApp.properties b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/resources/META-INF/ErraiApp.properties deleted file mode 100644 index 1e4ae2bf9d8..00000000000 --- a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/resources/META-INF/ErraiApp.properties +++ /dev/null @@ -1,33 +0,0 @@ -# -# 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. -# -# -# ErraiApp.properties -# -# Do not remove, even if empty! -# -# This is a marker file. When it is detected inside a JAR or at the -# top of any classpath, the subdirectories are scanned for deployable -# components. As such, all Errai application modules in a project -# should contain an ErraiApp.properties at the root of all classpaths -# that you wish to be scanned. -# -# There are also some configuration options that can be set in this -# file, although it is rarely necessary. See the documentation at -# https://docs.jboss.org/author/display/ERRAI/ErraiApp.properties -# for details. \ No newline at end of file diff --git a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/resources/org/appformer/kogito/bridge/AppformerKogitoBridge.gwt.xml b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/resources/org/appformer/kogito/bridge/AppformerKogitoBridge.gwt.xml deleted file mode 100644 index 2ac3c1baab9..00000000000 --- a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/main/resources/org/appformer/kogito/bridge/AppformerKogitoBridge.gwt.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - diff --git a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/test/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/PMMLEditorMarshallerServiceProducerTest.java b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/test/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/PMMLEditorMarshallerServiceProducerTest.java deleted file mode 100644 index 72146ec9ecb..00000000000 --- a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/test/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/PMMLEditorMarshallerServiceProducerTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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 org.appformer.kogito.bridge.client.pmmleditor.marshaller; - -import elemental2.dom.Console; -import elemental2.dom.DomGlobal; -import org.assertj.core.api.Assertions; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; - -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; - -@RunWith(MockitoJUnitRunner.class) -public class PMMLEditorMarshallerServiceProducerTest { - - @Mock - private Console console; - - private PMMLEditorMarshallerServiceProducer producer; - - @Before - public void setup() { - producer = spy(new PMMLEditorMarshallerServiceProducer()); - DomGlobal.console = console; - } - - @Test - public void produceWithEnvelopeAvailable() { - doReturn(true).when(producer).isEnvelopeAvailable(); - Assertions.assertThat(producer.produce()).isNotNull().isInstanceOf(PMMLEditorMarshallerService.class); - } - - @Test - public void produceWithEnvelopeNotAvailable() { - doReturn(false).when(producer).isEnvelopeAvailable(); - Assertions.assertThat(producer.produce()).isNotNull().isInstanceOf(UnavailablePMMLEditorMarshallerService.class); - verify(console).warn("[PMMLEditorMarshallerApi] Envelope API is not available. Empty PMML models will be passed"); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/test/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/PMMLEditorMarshallerServiceTest.java b/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/test/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/PMMLEditorMarshallerServiceTest.java deleted file mode 100644 index 49366297431..00000000000 --- a/packages/serverless-workflow-diagram-editor/appformer-kogito-bridge/src/test/java/org/appformer/kogito/bridge/client/pmmleditor/marshaller/PMMLEditorMarshallerServiceTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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 org.appformer.kogito.bridge.client.pmmleditor.marshaller; - -import org.appformer.kogito.bridge.client.pmmleditor.marshaller.model.PMMLDocumentData; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; - -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -@RunWith(MockitoJUnitRunner.class) -public class PMMLEditorMarshallerServiceTest { - - @Mock - private PMMLEditorMarshallerApiInteropWrapper wrapperMock; - - private PMMLEditorMarshallerService pmmlEditorMarshallerServiceSpy; - - @Before - public void setup() { - pmmlEditorMarshallerServiceSpy = spy(new PMMLEditorMarshallerService() { - @Override - PMMLEditorMarshallerApiInteropWrapper getWrapper() { - return wrapperMock; - } - }); - } - - @Test - public void getPMMLDocument() { - final String xmlContent = "content"; - when(wrapperMock.getPMMLDocumentData(xmlContent)).thenReturn(new PMMLDocumentData()); - pmmlEditorMarshallerServiceSpy.getPMMLDocumentData(xmlContent); - verify(wrapperMock, times(1)).getPMMLDocumentData(xmlContent); - } -} diff --git a/packages/serverless-workflow-diagram-editor/env/index.js b/packages/serverless-workflow-diagram-editor/env/index.js index 160d41c6c1d..946cb6c96eb 100644 --- a/packages/serverless-workflow-diagram-editor/env/index.js +++ b/packages/serverless-workflow-diagram-editor/env/index.js @@ -25,6 +25,11 @@ module.exports = composeEnv([require("@kie-tools/root-env/env")], { return { swfDiagramEditor: { version: require("../package.json").version, + UBERFIRE__version: "7.74.1.Final", + ANIMATE_CSS__version: "3.5.2", + BOOTSTRAP__version: "3.4.1", + FONT_AWESOME__version: "4.7.0", + GWTBOOTSTRAP3__version: "1.0.1", }, }; }, diff --git a/packages/serverless-workflow-diagram-editor/errai-api/pom.xml b/packages/serverless-workflow-diagram-editor/errai-api/pom.xml deleted file mode 100644 index b02d9633b3a..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-api/pom.xml +++ /dev/null @@ -1,73 +0,0 @@ - - 4.0.0 - - org.kie.kogito.stunner.serverless.editor - stunner-editors-parent - ${revision} - - errai-api - Errai::API - An aggregate jar of public API (annotations and interfaces) from various Errai modules. - - - - - maven-shade-plugin - - - package - - shade - - - - - - - org.jboss.errai:* - - - - - org.jboss.errai:* - - org/jboss/errai/bus/client/api/* - org/jboss/errai/bus/server/annotations/* - org/jboss/errai/enterprise/client/cdi/api/* - org/jboss/errai/common/client/api/annotations/* - org/jboss/errai/common/client/api/interceptor/* - org/jboss/errai/ui/cordova/Cordova.* - org/jboss/errai/databinding/client/api/* - org/jboss/errai/databinding/client/components/* - org/jboss/errai/ui/shared/api/annotations/* - org/jboss/errai/ui/client/local/spi/* - org/jboss/errai/ioc/client/api/* - org/jboss/errai/enterprise/shared/api/annotations/MapsFrom.* - org/jboss/errai/jpa/client/shared/GlobalEntityListener.* - org/jboss/errai/jpa/sync/client/local/Sync.* - org/jboss/errai/jpa/sync/client/local/SyncParam.* - org/jboss/errai/ui/nav/client/local/PageHidden.* - org/jboss/errai/ui/nav/client/local/PageHiding.* - org/jboss/errai/ui/nav/client/local/PageShowing.* - org/jboss/errai/ui/nav/client/local/PageShown.* - org/jboss/errai/ui/nav/client/local/PageState.* - org/jboss/errai/ui/nav/client/local/Page.* - org/jboss/errai/security/server/properties/ErraiAppProperties.* - org/jboss/errai/security/shared/api/annotation/RestrictedAccess.* - org/jboss/errai/ui/client/widget/OrderedList.* - org/jboss/errai/ui/client/widget/UnOrderedList.* - org/jboss/errai/ui/client/widget/Table.* - org/jboss/errai/ui/shared/api/annotations/* - - - - true - - - - - diff --git a/packages/serverless-workflow-diagram-editor/errai-bom/pom.xml b/packages/serverless-workflow-diagram-editor/errai-bom/pom.xml deleted file mode 100644 index 3e6d8697b0c..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-bom/pom.xml +++ /dev/null @@ -1,709 +0,0 @@ - - - 4.0.0 - - org.kie.kogito.stunner.serverless.editor - errai-bom - ${revision} - pom - JBoss Errai BOM - - http://erraiframework.org - - - - JBoss Errai Team - - - - - scm:git:git@github.com:errai/errai.git - scm:git:git@github.com:errai/errai.git - scm:git:git@github.com:errai/errai.git - - - - JBoss, a division of Red Hat - http://www.jboss.org - - - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - - - - jboss-releases-repository - JBoss Releases Repository - https://repository.jboss.org/nexus/service/local/staging/deploy/maven2/ - - - - jboss-snapshots-repository - JBoss Snapshots Repository - https://repository.jboss.org/nexus/content/repositories/snapshots/ - - - - - Dependency Management for all Errai third-party dependencies. - - - - - - - 0.10.0 - 1.7.6 - 7.1 - 1.5 - 3.0 - 3.5.0.1 - 2.10.0 - 8.0.1 - - - 5.0.20.Final - - 3.0.1.GA - 7.0.16.Final - 1.3.9 - 2.2.0 - - true - - 2.14.0-rc1 - 1.1.0 - 2.9.0 - 2.0.0 - - 3.17.0 - 1.1.9 - 0.0.2 - - 2.0.SP1 - 1 - 2.2 - 4.13.1 - - 3.8.1 - 1.5.1 - 3.3.9 - 2.1.3 - 3.0.0 - 3.23.2-GA - 1.0.0.GA - 1.4.0.Final - 2.5.0.Final - 3.3.2.Final - 3.11.2.Final - 2.0.0 - 2.2.0 - - 2.0.1.Final - 1.0.1.Final - 1.0.12.Final - 1.0.2.Final - 1.0.1.Final - 1.0.2.Final - 1.0.1.Final - 1.0.2.Final - 1.0.2.Final - 1.0.3.Final - 1.1.3.Final - 1.1.1.Final - 1.0.2.Final - 1.0.0.Final - 1.0.1.Final - 2.0.0.Final - 2.0.0.Final - 3.1.5.SP1 - 3.1.SP2 - 1.7.0.1.1 - 2.12.0 - 2.4.8.Final - 2.6.0.Final - 2.0.7 - 2.3.2 - 1.7.26 - 1.4.01 - - - - - jboss-public-repository-group - JBoss Public Repository Group - https://repository.jboss.org/nexus/content/groups/public/ - - true - never - - - true - daily - - - - - - - - - - org.kie.kogito.stunner.serverless.editor - errai-cdi-client - ${project.version} - - - - org.kie.kogito.stunner.serverless.editor - errai-cdi-shared - ${project.version} - - - - org.kie.kogito.stunner.serverless.editor - errai-cdi-client - test-jar - ${project.version} - - - - org.kie.kogito.stunner.serverless.editor - errai-codegen - ${project.version} - - - - org.kie.kogito.stunner.serverless.editor - errai-codegen-gwt - ${project.version} - - - - org.kie.kogito.stunner.serverless.editor - errai-codegen - test-jar - ${project.version} - - - - org.kie.kogito.stunner.serverless.editor - errai-common - ${project.version} - - - - org.kie.kogito.stunner.serverless.editor - errai-config - ${project.version} - - - - org.kie.kogito.stunner.serverless.editor - errai-ioc - ${project.version} - - - - org.kie.kogito.stunner.serverless.editor - errai-ioc - test-jar - ${project.version} - - - - org.kie.kogito.stunner.serverless.editor - errai-javax-enterprise - ${project.version} - - - - org.kie.kogito.stunner.serverless.editor - errai-ui - ${project.version} - - - - org.kie.kogito.stunner.serverless.editor - reflections - ${project.version} - - - - org.kie.kogito.stunner.serverless.editor - errai-api - ${project.version} - - - - - com.google.code.gson - gson - ${version.com.google.code.gson} - - - com.google.gwt.gwtmockito - gwtmockito - ${version.com.google.gwt.gwtmockito} - - - de.benediktmeurer.gwt-slf4j - gwt-slf4j - ${version.de.benediktmeurer.gwt-slf4j} - - - javax.enterprise - cdi-api - ${version.javax.enterprise} - - - javax.inject - javax.inject - ${version.javax.inject} - - - javax.persistence - javax.persistence-api - ${version.javax.persistence-api} - - - org.apache.deltaspike.core - deltaspike-core-api - ${version.org.apache.deltaspike.core} - - - org.apache.maven - maven-model-builder - ${version.org.apache.maven} - - - org.apache.maven - maven-builder-support - ${version.org.apache.maven} - - - org.apache.maven - maven-aether-provider - ${version.org.apache.maven} - - - org.dom4j - dom4j - ${version.org.dom4j} - - - org.mockito - mockito-core - ${version.org.mockito} - - - org.powermock - powermock-api-mockito2 - ${version.org.powermock} - - - org.powermock - powermock-module-junit4 - ${version.org.powermock} - - - - org.glassfish - javax.el - ${version.org.glassfish.javax.el} - - - - org.codehaus.gmaven - gmaven-mojo - ${gmaven.mojo.version} - - - - org.codehaus.gmaven - gmaven-mojo-support - ${gmaven.mojo.version} - - - org.javassist - javassist - ${version.org.javassist} - - - - javax.validation - validation-api - ${version.javax.validation} - - - org.mvel - mvel2 - ${version.org.mvel} - - - - org.slf4j - slf4j-api - ${version.org.slf4j} - - - - org.slf4j - slf4j-ext - ${version.org.slf4j} - - - - org.slf4j - slf4j-simple - ${version.org.slf4j} - - - org.slf4j - jcl-over-slf4j - ${version.org.slf4j} - - - org.slf4j - log4j-over-slf4j - ${version.org.slf4j} - - - org.twdata.maven - mojo-executor - ${mojo.executor.version} - - - org.quartz-scheduler - quartz - ${version.org.quartz-scheduler} - - - org.eclipse.jdt - ecj - ${version.org.eclipse.jdt.ecj} - - - - org.apache.stanbol - org.apache.stanbol.enhancer.engines.htmlextractor - ${apache.stanbol.htmlextractor.version} - - - org.ow2.asm - asm - ${asm.version} - - - javax - javaee-api - ${javaee.api.version} - - - org.jboss.logging - jboss-logging - ${version.org.jboss.logging.jboss-logging} - - - org.jboss.remoting - jboss-remoting - ${jboss.remoting.version} - - - org.jboss.resteasy - resteasy-cdi - ${version.org.jboss.resteasy} - - - org.jboss.resteasy - resteasy-jaxrs - ${version.org.jboss.resteasy} - - - org.jboss - jboss-common-core - ${version.org.jboss.jboss-common-core} - - - org.jboss.logging - jboss-logging-spi - - - - - org.jboss.web - jbossweb - ${jboss.web.version} - - - org.jboss.weld - weld-api - ${version.org.jboss.weld.weld-api} - - - org.jboss.weld - weld-core-impl - ${version.org.jboss.weld.weld} - - - javax.annotation - jsr250-api - - - - - org.jboss.weld - weld-spi - ${version.org.jboss.weld.weld-api} - - - org.jboss.weld.environment - weld-environment-common - ${version.org.jboss.weld.weld} - - - org.jboss.weld.se - weld-se-core - ${version.org.jboss.weld.weld} - - - javax.annotation - jsr250-api - - - - - org.jboss.weld.servlet - weld-servlet-core - ${version.org.jboss.weld.weld} - - - org.jboss.weld.module - weld-web - ${version.org.jboss.weld.weld} - - - org.jboss.weld.servlet - weld-servlet - ${version.org.jboss.weld.weld} - - - org.jboss.spec.javax.xml.bind - jboss-jaxb-api_2.3_spec - ${version.org.jboss.spec.javax.xml.bind} - - - org.gwtproject - gwt-user - ${gwt.version} - - - org.gwtproject - gwt-dev - ${gwt.version} - - - com.googlecode.gwtphonegap - gwtphonegap - ${gwt.phonegap.version} - - - com.google.jsinterop - jsinterop-annotations - ${version.com.google.jsinterop} - - - com.google.inject - guice - ${guice.version} - - - javax.inject - javax.inject - - - com.google.guava - guava - - - - - org.apache.commons - commons-lang3 - ${version.org.apache.commons.lang3} - - - - com.google.code.findbugs - jsr305 - ${jsr305.version} - - - - org.jboss.shrinkwrap.resolver - shrinkwrap-resolver-bom - ${version.org.jboss.shrinkwrap.resolver} - import - pom - - - org.jboss.arquillian - arquillian-bom - ${version.org.jboss.arquillian} - pom - import - - - org.jboss - jboss-vfs - ${jboss.vfs.version} - - - junit - junit - ${version.junit} - - - org.picketlink - picketlink-api - ${version.org.picketlink} - - - org.picketlink - picketlink-impl - ${version.org.picketlink} - - - org.lesscss - lesscss - ${version.org.lesscss} - - - com.fasterxml.jackson.core - jackson-databind - ${version.com.fasterxml.jackson} - - - com.fasterxml.jackson.core - jackson-core - ${version.com.fasterxml.jackson} - - - com.fasterxml.jackson.jaxrs - jackson-jaxrs-json-provider - ${version.com.fasterxml.jackson} - - - com.fasterxml.jackson.core - jackson-annotations - ${version.com.fasterxml.jackson} - - - org.jboss.spec.javax.annotation - jboss-annotations-api_1.3_spec - ${version.org.jboss.spec.javax.annotation.jboss-annotations-api_1.3_spec} - - - org.jboss.spec.javax.ejb - jboss-ejb-api_3.2_spec - ${version.org.jboss.spec.javax.ejb.jboss-ejb-api_3.2_spec} - - - org.jboss.spec.javax.enterprise.concurrent - jboss-concurrency-api_1.0_spec - ${version.org.jboss.spec.javax.enterprise.concurrent} - - - org.jboss.spec.javax.el - jboss-el-api_3.0_spec - ${version.org.jboss.spec.javax.el.jboss-el-api_3.0_spec} - - - org.jboss.spec.javax.interceptor - jboss-interceptors-api_1.2_spec - ${version.org.jboss.spec.javax.interceptor.jboss-interceptors-api_1.2_spec} - - - org.jboss.spec.javax.jms - jboss-jms-api_2.0_spec - ${version.org.jboss.spec.javax.jms.jboss-jms-api_2.0_spec} - - - org.jboss.spec.javax.resource - jboss-connector-api_1.7_spec - ${version.org.jboss.spec.javax.resource.jboss-connector-api_1.7_spec} - - - org.jboss.spec.javax.security.jacc - jboss-jacc-api_1.5_spec - ${version.org.jboss.spec.javax.security.jacc.jboss-jacc-api_1.5_spec} - - - org.jboss.spec.javax.servlet - jboss-servlet-api_3.1_spec - ${version.org.jboss.spec.javax.servlet.jboss-servlet-api_3.1_spec} - - - org.jboss.spec.javax.servlet.jsp - jboss-jsp-api_2.3_spec - ${version.org.jboss.spec.javax.servlet.jsp.jboss-jsp-api_2.3_spec} - - - org.jboss.spec.javax.servlet.jstl - jboss-jstl-api_1.2_spec - ${version.org.jboss.spec.javax.servlet.jstl.jboss-jstl-api_1.2_spec} - - - org.jboss.spec.javax.transaction - jboss-transaction-api_1.2_spec - ${version.org.jboss.spec.javax.transaction.jboss-transaction-api_1.2_spec} - - - org.jboss.spec.javax.ws.rs - jboss-jaxrs-api_2.1_spec - ${version.org.jboss.spec.javax.ws.rs.jboss-jaxrs-api_2.1_spec} - - - org.jboss.spec.javax.xml.ws - jboss-jaxws-api_2.3_spec - ${version.org.jboss.spec.javax.xml.ws.jboss-jaxws-api_2.3_spec} - - - org.jboss.spec.javax.websocket - jboss-websocket-api_1.1_spec - ${version.org.jboss.websocket.spec} - - - xml-apis - xml-apis - - ${version.xml-apis} - - - - diff --git a/packages/serverless-workflow-diagram-editor/errai-cdi/README.txt b/packages/serverless-workflow-diagram-editor/errai-cdi/README.txt deleted file mode 100644 index 065f2400154..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-cdi/README.txt +++ /dev/null @@ -1,18 +0,0 @@ - -Errai CDI Integration module -======================================= - -Build the project using: mvn clean install - -Troubleshooting -======================================= - -If you run into trouble don't hesitate to get in touch with us: - -User Forum: http://community.jboss.org/en/errai?view=discussions -Mailing List: http://jboss.org/errai/MailingLists.html -IRC: irc://irc.freenode.net/errai - - -Have fun, -The Errai Team \ No newline at end of file diff --git a/packages/serverless-workflow-diagram-editor/errai-cdi/RELEASE-PROCESS.md b/packages/serverless-workflow-diagram-editor/errai-cdi/RELEASE-PROCESS.md deleted file mode 100644 index c8427f8b22e..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-cdi/RELEASE-PROCESS.md +++ /dev/null @@ -1 +0,0 @@ -To release Errai-CDI, follow the release process for the base Errai project. diff --git a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/pom.xml b/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/pom.xml deleted file mode 100644 index de7165863ab..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/pom.xml +++ /dev/null @@ -1,158 +0,0 @@ - - - - org.kie.kogito.stunner.serverless.editor - cdi-integration-parent - ${revision} - ../pom.xml - - 4.0.0 - - errai-cdi-client - Errai::CDI::Client - - - - - src/main/java - - - src/main/resources - - - - - src/test/java - - - src/test/resources - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - test-jar - - - - **/AbstractErraiCDITest.* - - - - - - - - - - - org.kie.kogito.stunner.serverless.editor - errai-javax-enterprise - provided - - - - org.quartz-scheduler - quartz - provided - - - - org.kie.kogito.stunner.serverless.editor - errai-ioc - compile - - - javax.enterprise - cdi-api - - - javax.enterprise - cdi-api - - - javax.inject - javax.inject - - - org.jboss.spec.javax.annotation - jboss-annotations-api_1.2_spec - - - - - - org.kie.kogito.stunner.serverless.editor - errai-cdi-shared - - - - javax - javaee-api - provided - - - com.sun.mail - javax.mail - - - - - - - org.gwtproject - gwt-user - provided - - - - org.gwtproject - gwt-dev - provided - - - org.mortbay.jasper - apache-el - - - org.mortbay.jasper - apache-jsp - - - javax.servlet - javax.servlet-api - - - com.sun.mail - javax.mail - - - javax.servlet - javax.servlet-api - - - org.eclipse.jetty - jetty-annotations - - - - - - junit - junit - provided - - - - - diff --git a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/src/main/java/org/jboss/errai/enterprise/CDI.gwt.xml b/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/src/main/java/org/jboss/errai/enterprise/CDI.gwt.xml deleted file mode 100644 index 0ff66fa2ae5..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/src/main/java/org/jboss/errai/enterprise/CDI.gwt.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - diff --git a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/src/main/java/org/jboss/errai/enterprise/client/cdi/CDIClientBootstrap.java b/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/src/main/java/org/jboss/errai/enterprise/client/cdi/CDIClientBootstrap.java deleted file mode 100644 index a8e4bd252ac..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/src/main/java/org/jboss/errai/enterprise/client/cdi/CDIClientBootstrap.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 org.jboss.errai.enterprise.client.cdi; - -import com.google.gwt.core.client.EntryPoint; -import com.google.gwt.core.client.GWT; -import org.jboss.errai.common.client.api.extension.InitVotes; -import org.jboss.errai.enterprise.client.cdi.api.CDI; -import org.jboss.errai.enterprise.client.cdi.events.BusReadyEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The GWT entry point for the Errai CDI module. - * - * @author Mike Brock - * @author Christian Sadilek - */ -public class CDIClientBootstrap implements EntryPoint { - - private static final Logger logger = LoggerFactory.getLogger(CDIClientBootstrap.class); - - @Override - public void onModuleLoad() { - logger.debug("Starting CDI module..."); - if (!EventQualifierSerializer.isSet()) { - EventQualifierSerializer.set(GWT.create(EventQualifierSerializer.class)); - } - - InitVotes.registerPersistentPreInitCallback(() -> {}); - InitVotes.waitFor(CDI.class); - - CDI.activate(); - CDI.fireEvent(new BusReadyEvent()); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/src/main/java/org/jboss/errai/enterprise/client/cdi/EventProvider.java b/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/src/main/java/org/jboss/errai/enterprise/client/cdi/EventProvider.java deleted file mode 100644 index 25c9d7a5013..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/src/main/java/org/jboss/errai/enterprise/client/cdi/EventProvider.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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 org.jboss.errai.enterprise.client.cdi; - -import java.lang.annotation.Annotation; - -import javax.enterprise.event.Event; -import javax.inject.Singleton; - -import org.jboss.errai.enterprise.client.cdi.api.CDI; -import org.jboss.errai.ioc.client.api.ContextualTypeProvider; -import org.jboss.errai.ioc.client.api.IOCProvider; - -@IOCProvider -@Singleton -public class EventProvider implements ContextualTypeProvider { - - @Override - public Event provide(final Class[] typeargs, final Annotation[] qualifiers) { - - /* - * If you see a compile error here, ensure that you are using Errai's custom - * version of javax.enterprise.event.Event, which comes from the - * errai-javax-enterprise project. The errai-cdi-client POM is set up this - * way. - * - * Eclipse users: seeing an error here probably indicates that M2E has - * clobbered your errai-javax-enterprise source folder settings. To fix your - * setup, see the README in the root of errai-javax-enterprise. - */ - final Class eventType = (typeargs.length == 1 ? typeargs[0] : Object.class); - return new EventImpl(eventType, qualifiers); - } - - private static class EventImpl implements Event { - private final Class eventType; - private final Annotation[] _qualifiers; - - private EventImpl(final Class eventType, - final Annotation[] _qualifiers) { - - this.eventType = eventType; - this._qualifiers = _qualifiers; - } - - public void fire(final Object event) { - if (event == null) - return; - - CDI.fireEvent(event, _qualifiers); - } - - @Override - public Event select(final Annotation... qualifiers) { - if (qualifiers == null) return this; - return new EventImpl(eventType, concat(_qualifiers, qualifiers)); - } - - @Override - public Event select(final Class subtype, final Annotation... qualifiers) { - return (Event) new EventImpl(subtype, concat(_qualifiers, qualifiers)); - } - - private static Annotation[] concat(Annotation[] a, Annotation[] b) { - if (a == null) { - return b; - } - else if (b == null) { - return a; - } - - final Annotation[] newQualifiers = new Annotation[a.length + b.length]; - for (int i = 0; i < a.length; i++) { - newQualifiers[i] = a[i]; - } - - for (int i = 0; i < b.length; i++) { - newQualifiers[i + a.length] = b[i]; - } - - return newQualifiers; - } - - - public Class getEventType() { - return eventType; - } - - public Annotation[] getQualifiers() { - return _qualifiers; - } - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/src/main/java/org/jboss/errai/enterprise/client/cdi/InstanceProvider.java b/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/src/main/java/org/jboss/errai/enterprise/client/cdi/InstanceProvider.java deleted file mode 100644 index 7f96f10af3f..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/src/main/java/org/jboss/errai/enterprise/client/cdi/InstanceProvider.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * 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 org.jboss.errai.enterprise.client.cdi; - -import java.lang.annotation.Annotation; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; - -import javax.enterprise.inject.Instance; -import javax.inject.Singleton; - -import org.jboss.errai.ioc.client.IOCUtil; -import org.jboss.errai.ioc.client.api.ContextualTypeProvider; -import org.jboss.errai.ioc.client.api.IOCProvider; -import org.jboss.errai.ioc.client.container.IOC; -import org.jboss.errai.ioc.client.container.SyncBeanDef; - -import static org.jboss.errai.ioc.client.IOCUtil.joinQualifiers; -import static org.jboss.errai.ioc.client.QualifierUtil.DEFAULT_ANNOTATION; -import static org.jboss.errai.ioc.client.container.IOC.getBeanManager; - -@SuppressWarnings("rawtypes") -@IOCProvider -@Singleton -public class InstanceProvider implements ContextualTypeProvider { - - @SuppressWarnings("unchecked") - @Override - public Instance provide(final Class[] typeargs, final Annotation[] qualifiers) { - - /* - * If you see a compile error here, ensure that you are using Errai's custom - * version of javax.enterprise.event.Event, which comes from the - * errai-javax-enterprise project. The errai-cdi-client POM is set up this - * way. - * - * Eclipse users: seeing an error here probably indicates that M2E has - * clobbered your errai-javax-enterprise source folder settings. To fix your - * setup, see the README in the root of errai-javax-enterprise. - */ - - return new InstanceImpl(typeargs[0], qualifiers.length == 0 ? new Annotation[] { DEFAULT_ANNOTATION } : qualifiers); - } - - static class InstanceImpl implements Instance { - private final Class type; - private final Annotation[] qualifiers; - - InstanceImpl(final Class type, final Annotation[] qualifiers) { - this.type = type; - this.qualifiers = qualifiers; - } - - @Override - public Instance select(final Annotation... qualifiers) { - return select(type, qualifiers); - } - - @Override - public Instance select(final Class subtype, final Annotation... qualifiers) { - return new InstanceImpl(subtype, joinQualifiers(this.qualifiers, qualifiers)); - } - - @Override - public boolean isUnsatisfied() { - return IOCUtil.isUnsatisfied(type, qualifiers); - } - - @Override - public boolean isAmbiguous() { - return IOCUtil.isAmbiguous(type, qualifiers); - } - - @Override - public Iterator iterator() { - final Collection> beanDefs = IOC.getBeanManager().lookupBeans( type, qualifiers ); - if (beanDefs==null){ - return Collections.emptyList().iterator(); - } - return new InstanceImplIterator(beanDefs); - } - - @Override - public T get() { - return IOCUtil.getInstance(type, qualifiers); - } - - @Override - public void destroy(final Object instance) { - getBeanManager().destroyBean(instance); - } - - private class InstanceImplIterator implements Iterator { - - private final Iterator> delegate; - - public InstanceImplIterator( final Collection> beanDefs ) { - this.delegate = beanDefs.iterator(); - } - - @Override - public boolean hasNext() { - return delegate.hasNext(); - } - - @Override - public T next() { - return delegate.next().getInstance(); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - } - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/src/main/java/org/jboss/errai/enterprise/client/cdi/events/BusReadyEvent.java b/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/src/main/java/org/jboss/errai/enterprise/client/cdi/events/BusReadyEvent.java deleted file mode 100644 index b3b2c0d3dec..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/src/main/java/org/jboss/errai/enterprise/client/cdi/events/BusReadyEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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 org.jboss.errai.enterprise.client.cdi.events; - -import org.jboss.errai.ioc.client.api.AfterInitialization; - -/** - * An event that is fired locally on the client after the ErraiBus has completed - * federation with the server. All remote (server-side) CDI services are known - * before this event is fired. - *

- * Usage note: methods annotated with {@link AfterInitialization} are - * also called after remote service discovery, and these methods are often an - * easier way of arranging for client-side startup code to execute. - * - * @author Mike Brock . - */ -public class BusReadyEvent {} diff --git a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/src/main/java/org/jboss/errai/enterprise/rebind/EventQualifierSerializerGenerator.java b/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/src/main/java/org/jboss/errai/enterprise/rebind/EventQualifierSerializerGenerator.java deleted file mode 100644 index b424a2a4e52..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/src/main/java/org/jboss/errai/enterprise/rebind/EventQualifierSerializerGenerator.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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 org.jboss.errai.enterprise.rebind; - -import javax.inject.Qualifier; - -import com.google.gwt.core.ext.GeneratorContext; -import com.google.gwt.core.ext.TreeLogger; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.config.rebind.AbstractAsyncGenerator; -import org.jboss.errai.config.rebind.GenerateAsync; -import org.jboss.errai.enterprise.client.cdi.EventQualifierSerializer; -import org.jboss.errai.ioc.util.TranslatableAnnotationUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static org.jboss.errai.enterprise.client.cdi.EventQualifierSerializer.SERIALIZER_CLASS_NAME; -import static org.jboss.errai.enterprise.client.cdi.EventQualifierSerializer.SERIALIZER_PACKAGE_NAME; - -/** - * - * @author Max Barkley - */ -@GenerateAsync(EventQualifierSerializer.class) -public class EventQualifierSerializerGenerator extends AbstractAsyncGenerator { - - private static final Logger logger = LoggerFactory.getLogger(EventQualifierSerializerGenerator.class); - - @Override - public String generate(final TreeLogger logger, final GeneratorContext context, final String typeName) { - return startAsyncGeneratorsAndWaitFor(EventQualifierSerializer.class, context, logger, SERIALIZER_PACKAGE_NAME, SERIALIZER_CLASS_NAME); - } - - @Override - protected String generate(final TreeLogger treeLogger, final GeneratorContext context) { - logger.info("Generating {}.{}...", SERIALIZER_PACKAGE_NAME, SERIALIZER_CLASS_NAME); - return NonGwtEventQualifierSerializerGenerator.generateSource(TranslatableAnnotationUtils.getTranslatableQualifiers(context.getTypeOracle())); - } - - @Override - protected boolean isRelevantClass(final MetaClass clazz) { - return clazz.isAnnotation() && clazz.isAnnotationPresent(Qualifier.class); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/src/main/java/org/jboss/errai/enterprise/rebind/JSR299IOCExtensionConfigurator.java b/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/src/main/java/org/jboss/errai/enterprise/rebind/JSR299IOCExtensionConfigurator.java deleted file mode 100644 index 63978b76c59..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/src/main/java/org/jboss/errai/enterprise/rebind/JSR299IOCExtensionConfigurator.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * 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 org.jboss.errai.enterprise.rebind; - -import java.util.HashSet; -import java.util.Set; - -import javax.enterprise.event.Observes; -import javax.enterprise.inject.Produces; - -import org.jboss.errai.codegen.BlockStatement; -import org.jboss.errai.codegen.Modifier; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.builder.MethodCommentBuilder; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaParameter; -import org.jboss.errai.codegen.util.Stmt; -import org.jboss.errai.config.util.ClassScanner; -import org.jboss.errai.enterprise.client.cdi.CDIEventTypeLookup; -import org.jboss.errai.enterprise.client.cdi.api.CDI; -import org.jboss.errai.ioc.client.api.IOCExtension; -import org.jboss.errai.ioc.rebind.ioc.bootstrapper.IOCProcessingContext; -import org.jboss.errai.ioc.rebind.ioc.extension.IOCExtensionConfigurator; -import org.jboss.errai.ioc.rebind.ioc.injector.api.InjectionContext; -import org.jboss.errai.ioc.rebind.ioc.injector.api.WiringElementType; - -@IOCExtension -public class JSR299IOCExtensionConfigurator implements IOCExtensionConfigurator { - @Override - public void configure(final IOCProcessingContext context, final InjectionContext injectionContext) { - injectionContext.mapElementType(WiringElementType.ProducerElement, Produces.class); - } - - @SuppressWarnings("unchecked") - private static void addTypeHierarchyFor(final IOCProcessingContext context, final Set classes) { - final BlockStatement instanceInitializer = context.getBootstrapClass().getInstanceInitializer(); - - int i = 0, addLookupMethodCount = 0; - MethodCommentBuilder currentBlock = null; - for (final MetaClass subClass : classes) { - // We'll generate a separate lookup method for every 500 lines to make sure we're not - // exceeding the method size byte limit. See ERRAI-346 and ERRAI-679 - if ((i++ % 500) == 0) { - final Statement lookupMethod = Stmt.invokeStatic(context.getBootstrapClass(), "addLookups_" + addLookupMethodCount); - if (currentBlock != null) { - currentBlock - .append(lookupMethod); - currentBlock.modifiers(Modifier.Static).finish(); - } - else { - instanceInitializer.addStatement(lookupMethod); - } - currentBlock = - context.getBootstrapBuilder().privateMethod(void.class, "addLookups_" + addLookupMethodCount++); - } - - if (subClass.getSuperClass() != null) { - currentBlock.append(Stmt.invokeStatic(CDIEventTypeLookup.class, "get") - .invoke("addLookup", subClass.getFullyQualifiedName(), subClass.getSuperClass().getFullyQualifiedName())); - } - - for (final MetaClass interfaceClass : subClass.getInterfaces()) { - currentBlock.append(Stmt.invokeStatic(CDIEventTypeLookup.class, "get") - .invoke("addLookup", subClass.getFullyQualifiedName(), interfaceClass.getFullyQualifiedName())); - - } - } - - if (currentBlock != null) { - currentBlock.modifiers(Modifier.Static).finish(); - } - } - - @Override - public void afterInitialization(final IOCProcessingContext context, final InjectionContext injectionContext) { - - final BlockStatement instanceInitializer = context.getBootstrapClass().getInstanceInitializer(); - final Set knownObserverTypes = new HashSet<>(); - - for (final MetaParameter parameter : ClassScanner.getParametersAnnotatedWith(Observes.class, - context.getGeneratorContext())) { - knownObserverTypes.add(parameter.getType()); - } - - final Set knownTypesWithSuperTypes = new HashSet<>(knownObserverTypes); - for (final MetaClass cls : knownObserverTypes) { - for (final MetaClass subClass : ClassScanner.getSubTypesOf(cls, context.getGeneratorContext())) { - knownTypesWithSuperTypes.add(subClass); - } - } - - addTypeHierarchyFor(context, knownTypesWithSuperTypes); - - instanceInitializer.addStatement(Stmt.nestedCall(Stmt.newObject(CDI.class)) - .invoke("initLookupTable", Stmt.invokeStatic(CDIEventTypeLookup.class, "get"))); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/src/main/java/org/jboss/errai/enterprise/rebind/ObservesExtension.java b/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/src/main/java/org/jboss/errai/enterprise/rebind/ObservesExtension.java deleted file mode 100644 index 11dce54459d..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/src/main/java/org/jboss/errai/enterprise/rebind/ObservesExtension.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * 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 org.jboss.errai.enterprise.rebind; - -import java.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import javax.enterprise.event.Observes; -import javax.enterprise.inject.Any; - -import jsinterop.annotations.JsType; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Parameter; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.builder.AnonymousClassStructureBuilder; -import org.jboss.errai.codegen.builder.BlockBuilder; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaMethod; -import org.jboss.errai.codegen.meta.MetaParameter; -import org.jboss.errai.codegen.util.Refs; -import org.jboss.errai.codegen.util.Stmt; -import org.jboss.errai.enterprise.client.cdi.AbstractCDIEventCallback; -import org.jboss.errai.enterprise.client.cdi.EventQualifierSerializer; -import org.jboss.errai.enterprise.client.cdi.JsTypeEventObserver; -import org.jboss.errai.enterprise.client.cdi.api.CDI; -import org.jboss.errai.enterprise.client.cdi.api.Subscription; -import org.jboss.errai.ioc.client.api.CodeDecorator; -import org.jboss.errai.ioc.client.container.Factory; -import org.jboss.errai.ioc.rebind.ioc.bootstrapper.InjectUtil; -import org.jboss.errai.ioc.rebind.ioc.extension.IOCDecoratorExtension; -import org.jboss.errai.ioc.rebind.ioc.injector.api.Decorable; -import org.jboss.errai.ioc.rebind.ioc.injector.api.FactoryController; - -import static org.jboss.errai.codegen.meta.MetaClassFactory.parameterizedAs; -import static org.jboss.errai.codegen.meta.MetaClassFactory.typeParametersOf; -import static org.jboss.errai.codegen.util.Stmt.castTo; -import static org.jboss.errai.codegen.util.Stmt.declareFinalVariable; -import static org.jboss.errai.codegen.util.Stmt.invokeStatic; - -/** - * Generates the boiler plate for @Observes annotations use in GWT clients.
- * Basically creates a subscription for a CDI event type that invokes on the annotated method. - * - * @author Heiko Braun - * @author Mike Brock - * @author Christian Sadilek - * @author Max Barkley - */ -@CodeDecorator -public class ObservesExtension extends IOCDecoratorExtension { - public ObservesExtension(final Class decoratesWith) { - super(decoratesWith); - } - - @Override - public void generateDecorator(final Decorable decorable, final FactoryController controller) { - if (!EventQualifierSerializer.isSet()) { - NonGwtEventQualifierSerializerGenerator.loadAndSetEventQualifierSerializer(); - } - - final Context ctx = decorable.getCodegenContext(); - final MetaParameter parm = decorable.getAsParameter(); - final MetaMethod method = (MetaMethod) parm.getDeclaringMember(); - - controller.ensureMemberExposed(parm); - - final MetaClass eventType = parm.getType().asBoxed(); - final String parmClassName = eventType.getFullyQualifiedName(); - final List annotations = InjectUtil.extractQualifiers(parm); - final Annotation[] qualifiers = annotations.toArray(new Annotation[annotations.size()]); - final Set qualifierNames = new HashSet<>(CDI.getQualifiersPart(qualifiers)); - final boolean isEnclosingTypeDependent = enclosingTypeIsDependentScoped(decorable); - - if (qualifierNames.contains(Any.class.getName())) { - qualifierNames.remove(Any.class.getName()); - } - - final MetaClass callBackType = parameterizedAs(AbstractCDIEventCallback.class, typeParametersOf(eventType)); - - AnonymousClassStructureBuilder callBack = Stmt.newObject(callBackType).extend(); - - BlockBuilder callBackBlock; - - if (!qualifierNames.isEmpty()) { - callBackBlock = callBack.initialize(); - for (final String qualifierName : qualifierNames) { - callBackBlock.append(Stmt.loadClassMember("qualifierSet").invoke("add", qualifierName)); - } - callBack = callBackBlock.finish(); - } - - final List callbackStatements = new ArrayList<>(); - if (!isEnclosingTypeDependent) { - callbackStatements - .add(declareFinalVariable("instance", decorable.getDecorableDeclaringType(), castTo(decorable.getEnclosingInjectable().getInjectedType(), - invokeStatic(Factory.class, "maybeUnwrapProxy", controller.contextGetInstanceStmt())))); - } - callbackStatements.add(decorable.call(Refs.get("event"))); - - callBackBlock = callBack.publicOverridesMethod("fireEvent", Parameter.finalOf(eventType, "event")) - .appendAll(callbackStatements) - .finish() - .publicOverridesMethod("toString") - ._(Stmt.load("Observer: " + parmClassName + " " + Arrays.toString(qualifiers)).returnValue()); - - final List initStatements = new ArrayList<>(); - final List destroyStatements = new ArrayList<>(); - final String subscrVar = method.getName() + "Subscription"; - - final String subscribeMethod; - - if (eventType.isAnnotationPresent(JsType.class)) { - subscribeMethod = "subscribeJsType"; - callBackBlock = getJsTypeSubscriptionCallback(decorable, controller); - } else { - subscribeMethod = "subscribeLocal"; - callBackBlock = getSubscriptionCallback(decorable, controller); - } - - final Statement subscribeStatement = Stmt.create(ctx).invokeStatic(CDI.class, subscribeMethod, parmClassName, - callBackBlock.finish().finish()); - - if (isEnclosingTypeDependent) { - initStatements.add(controller.setReferenceStmt(subscrVar, subscribeStatement)); - destroyStatements.add(controller.getReferenceStmt(subscrVar, Subscription.class).invoke("remove")); - } else { - initStatements.add(subscribeStatement); - } - - if (isEnclosingTypeDependent) { - controller.addInitializationStatements(initStatements); - controller.addDestructionStatements(destroyStatements); - } else { - controller.addFactoryInitializationStatements(initStatements); - } - } - - private boolean enclosingTypeIsDependentScoped(final Decorable decorable) { - return decorable.isEnclosingTypeDependent(); - } - - private BlockBuilder getSubscriptionCallback(final Decorable decorable, final FactoryController controller) { - - final MetaParameter parm = decorable.getAsParameter(); - final MetaClass eventType = parm.getType().asBoxed(); - final String parmClassName = eventType.getFullyQualifiedName(); - final List annotations = InjectUtil.extractQualifiers(parm); - final Annotation[] qualifiers = annotations.toArray(new Annotation[0]); - final Set qualifierNames = new HashSet<>(CDI.getQualifiersPart(qualifiers)); - - final MetaClass callBackType = parameterizedAs(AbstractCDIEventCallback.class, typeParametersOf(eventType)); - AnonymousClassStructureBuilder callBack = Stmt.newObject(callBackType).extend(); - BlockBuilder callBackBlock; - - if (!qualifierNames.isEmpty()) { - callBackBlock = callBack.initialize(); - for (final String qualifierName : qualifierNames) { - callBackBlock.append(Stmt.loadClassMember("qualifierSet").invoke("add", qualifierName)); - } - callBack = callBackBlock.finish(); - } - - final List fireEventStmts = new ArrayList<>(); - if (!decorable.isEnclosingTypeDependent()) { - fireEventStmts.add(Stmt.declareFinalVariable("instance", decorable.getEnclosingInjectable().getInjectedType(), - Stmt.invokeStatic(Factory.class, "maybeUnwrapProxy", controller.contextGetInstanceStmt()))); - } - fireEventStmts.add(decorable.call(Refs.get("event"))); - - callBackBlock = callBack.publicOverridesMethod("fireEvent", Parameter.finalOf(eventType, "event")) - .appendAll(fireEventStmts) - .finish() - .publicOverridesMethod("toString") - ._(Stmt.load("Observer: " + parmClassName + " " + Arrays.toString(qualifiers)).returnValue()); - - return callBackBlock; - } - - private BlockBuilder getJsTypeSubscriptionCallback(final Decorable decorable, final FactoryController controller) { - - final MetaParameter parm = decorable.getAsParameter(); - final MetaClass eventType = parm.getType().asBoxed(); - final String parmClassName = eventType.getFullyQualifiedName(); - - final MetaClass callBackType = parameterizedAs(JsTypeEventObserver.class, typeParametersOf(eventType)); - final AnonymousClassStructureBuilder callBack = Stmt.newObject(callBackType).extend(); - BlockBuilder callBackBlock; - - final List fireEventStmts = new ArrayList<>(); - if (!decorable.isEnclosingTypeDependent()) { - fireEventStmts.add(Stmt.declareFinalVariable("instance", decorable.getEnclosingInjectable().getInjectedType(), - Stmt.invokeStatic(Factory.class, "maybeUnwrapProxy", controller.contextGetInstanceStmt()))); - } - fireEventStmts.add(decorable.call(Refs.get("event"))); - - callBackBlock = callBack.publicOverridesMethod("onEvent", Parameter.finalOf(eventType, "event")) - .appendAll(fireEventStmts) - .finish() - .publicOverridesMethod("toString") - ._(Stmt.load("JsTypeObserver: " + parmClassName).returnValue()); - - return callBackBlock; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/src/main/resources/META-INF/ErraiApp.properties b/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/src/main/resources/META-INF/ErraiApp.properties deleted file mode 100644 index 7765a670d6e..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/src/main/resources/META-INF/ErraiApp.properties +++ /dev/null @@ -1,17 +0,0 @@ -# -# ErraiApp.properties -# -# Do not remove, even if empty! -# - -# This is a marker file. When it is detected inside a JAR or at the -# top of any classpath, the subdirectories are scanned for deployable -# components. As such, all Errai application modules in a project -# should contain an ErraiApp.properties at the root of all classpaths -# that you wish to be scanned. -# -# There are also some configuration options that can be set in this -# file, although it is rarely necessary. See the documentation at -# https://docs.jboss.org/author/display/ERRAI/ErraiApp.properties -# for details. - diff --git a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/src/test/java/org/jboss/errai/enterprise/client/cdi/AbstractErraiCDITest.java b/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/src/test/java/org/jboss/errai/enterprise/client/cdi/AbstractErraiCDITest.java deleted file mode 100644 index dd2b3cbc10a..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-client/src/test/java/org/jboss/errai/enterprise/client/cdi/AbstractErraiCDITest.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * 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 org.jboss.errai.enterprise.client.cdi; - -import java.lang.annotation.Annotation; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import com.google.gwt.junit.client.GWTTestCase; -import com.google.gwt.user.client.Timer; -import org.jboss.errai.common.client.api.extension.InitVotes; -import org.jboss.errai.enterprise.client.cdi.api.CDI; -import org.jboss.errai.ioc.client.Container; -import org.jboss.errai.ioc.client.QualifierUtil; -import org.jboss.errai.ioc.client.container.IOC; -import org.jboss.errai.ioc.client.container.SyncBeanDef; - -/** - * Abstract base class of all Errai CDI integration tests, - * used to bootstrap our IOC container and CDI module. - * - * @author Christian Sadilek - */ -public abstract class AbstractErraiCDITest extends GWTTestCase { - - protected boolean disableBus = false; - - @Override - protected void gwtSetUp() throws Exception { - if (disableBus) { - setRemoteCommunicationEnabled(false); - } - InitVotes.setTimeoutMillis(60000); - - // Unfortunately, GWTTestCase does not call our inherited module's onModuleLoad() methods - // http://code.google.com/p/google-web-toolkit/issues/detail?id=3791 - new CDI().__resetSubsystem(); - new Container().onModuleLoad(); - new CDIClientBootstrap().onModuleLoad(); - - InitVotes.startInitPolling(); - - super.gwtSetUp(); - } - - @Override - protected void gwtTearDown() throws Exception { - setRemoteCommunicationEnabled(true); - InitVotes.reset(); - IOC.reset(); - Container.reset(); - super.gwtTearDown(); - } - - public static boolean annotationSetMatches(final Set annotations, - final Class... annos) { - - final Set> annoClassCompareFrom - = new HashSet<>(Arrays.asList(annos)); - - final Set> annoClassCompareTo - = new HashSet<>(); - - for (final Annotation a : annotations) { - annoClassCompareTo.add(a.annotationType()); - } - - return annoClassCompareFrom.equals(annoClassCompareTo); - } - - public native void setRemoteCommunicationEnabled(boolean enabled) /*-{ - $wnd.erraiBusRemoteCommunicationEnabled = enabled; - }-*/; - - protected Collection> getBeans(final Class type, - final Annotation... annotations) { - return IOC.getBeanManager().lookupBeans(type, annotations); - } - - protected boolean assertContains(final Collection annotationCollection, - final Annotation toCompare) { - for (final Annotation a : annotationCollection) { - if (QualifierUtil.isEqual(a, toCompare)) return true; - } - return false; - } - - protected void asyncTest() { - delayTestFinish(90000); - } - - protected void asyncTest(final Runnable runnable) { - asyncTest(); - InitVotes.registerOneTimeInitCallback(new Runnable() { - - @Override - public void run() { - new Timer() { - @Override - public void run() { - runnable.run(); - } - }.schedule(100); - } - }); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/pom.xml b/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/pom.xml deleted file mode 100644 index 57279e82c7d..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/pom.xml +++ /dev/null @@ -1,105 +0,0 @@ - - 4.0.0 - - org.kie.kogito.stunner.serverless.editor - cdi-integration-parent - ${revision} - ../pom.xml - - - errai-cdi-shared - Errai::CDI::Shared - - - - - src/main/java - - - src/main/resources - - - - - src/test/java - - - src/test/resources - - - - - - - org.kie.kogito.stunner.serverless.editor - errai-common - - - - org.kie.kogito.stunner.serverless.editor - errai-ioc - provided - - - javax.enterprise - cdi-api - - - org.jboss.spec.javax.annotation - jboss-annotations-api_1.2_spec - - - javax.inject - javax.inject - - - - - org.gwtproject - gwt-user - provided - - - org.gwtproject - gwt-dev - provided - - - org.eclipse.jetty - jetty-annotations - - - org.mortbay.jasper - apache-el - - - org.mortbay.jasper - apache-jsp - - - com.sun.mail - javax.mail - - - javax.servlet - javax.servlet-api - - - - - javax - javaee-api - provided - - - com.sun.mail - javax.mail - - - - - diff --git a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/CDIShared.gwt.xml b/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/CDIShared.gwt.xml deleted file mode 100644 index 8afbdb7ca43..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/CDIShared.gwt.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - diff --git a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/AbstractCDIEventCallback.java b/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/AbstractCDIEventCallback.java deleted file mode 100644 index 50c56d7e964..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/AbstractCDIEventCallback.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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 org.jboss.errai.enterprise.client.cdi; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -import javax.enterprise.inject.Any; - -import org.jboss.errai.enterprise.client.cdi.api.Message; -import org.jboss.errai.enterprise.client.cdi.api.MessageCallback; - -/** - * @author Christian Sadilek - * @author Mike Brock - */ -public abstract class AbstractCDIEventCallback implements MessageCallback { - /** - * The qualifiers a message must contain to be propagated. - */ - protected final Set qualifierSet = new HashSet(); - - public Set getQualifiers() { - return qualifierSet; - } - - @SuppressWarnings("unchecked") - @Override - public final void callback(final Message message) { - Set msgQualifiers = message.get(Set.class, CDIProtocol.Qualifiers); - - if (msgQualifiers == null) { - msgQualifiers = Collections.emptySet(); - } - - if (message.hasPart(CDIProtocol.FromClient)) { - if (isDefault() || msgQualifiers.containsAll(qualifierSet)) { - fireEvent((T) message.get(Object.class, CDIProtocol.BeanReference)); - } - } - else { - // Our server-side CDI integration module knows of all client-side event - // observers and sends a separate message specific to each matching - // observer. - if (msgQualifiers.equals(qualifierSet)) { - fireEvent((T) message.get(Object.class, CDIProtocol.BeanReference)); - } - } - } - - protected boolean isDefault() { - return qualifierSet.size() == 1 && qualifierSet.contains(Any.class.getName()); - } - - protected abstract void fireEvent(T event); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/CDICommands.java b/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/CDICommands.java deleted file mode 100644 index 10888970c8b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/CDICommands.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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 org.jboss.errai.enterprise.client.cdi; - -public enum CDICommands { - CDIEvent, AttachRemote, RemoteSubscribe, RemoteUnsubscribe -} diff --git a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/CDIEventTypeLookup.java b/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/CDIEventTypeLookup.java deleted file mode 100644 index 11090c461a0..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/CDIEventTypeLookup.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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 org.jboss.errai.enterprise.client.cdi; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; - -import static java.util.Collections.unmodifiableMap; - -/** - * @author Mike Brock - */ -public final class CDIEventTypeLookup { - private Map> typeLookup = new HashMap>(); - - private CDIEventTypeLookup() { - } - - private final static CDIEventTypeLookup typeLookupSingleton = new CDIEventTypeLookup(); - - public static CDIEventTypeLookup get() { - return typeLookupSingleton; - } - - /** - * Returns a defensively copied, unmodifiable Map of all sub-types to their supertypes. - * - * @return a defensively copied, unmodifiable Map of all sub-types to their supertypes. - */ - public Map> getTypeLookupMap() { - // build a defensive copy of the type lookup map. - - Map> newLookupMap = new HashMap>(); - for (Map.Entry> entry : typeLookup.entrySet()) { - newLookupMap.put(entry.getKey(), Collections.unmodifiableSet(new LinkedHashSet(entry.getValue()))); - } - - return unmodifiableMap(newLookupMap); - } - - public void addLookup(final String subtype, final String superType) { - Collection superTypes = typeLookup.get(subtype); - if (superTypes == null) { - typeLookup.put(subtype, superTypes = new LinkedHashSet()); - } - superTypes.add(superType); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/CDIProtocol.java b/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/CDIProtocol.java deleted file mode 100644 index 627b17e33e7..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/CDIProtocol.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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 org.jboss.errai.enterprise.client.cdi; - -public enum CDIProtocol { - BeanType, Qualifiers, BeanReference, ObservedTypes, FromClient -} diff --git a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/EventQualifierSerializer.java b/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/EventQualifierSerializer.java deleted file mode 100644 index 58da44739c9..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/EventQualifierSerializer.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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 org.jboss.errai.enterprise.client.cdi; - -import java.lang.annotation.Annotation; -import java.util.HashMap; -import java.util.Map; - -import org.jboss.errai.common.client.api.Assert; -import org.jboss.errai.common.client.util.AnnotationPropertyAccessor; -import org.jboss.errai.common.client.util.SharedAnnotationSerializer; - -/** - * - * @author Max Barkley - */ -public abstract class EventQualifierSerializer { - - public static final String SERIALIZER_CLASS_NAME = "EventQualifierSerializerImpl"; - public static final String SERIALIZER_PACKAGE_NAME = "org.jboss.errai.cdi"; - - private static EventQualifierSerializer instance; - - public static boolean isSet() { - return instance != null; - } - - public static void set(final EventQualifierSerializer impl) { - if (instance == null) { - instance = Assert.notNull(impl); - } - else { - throw new RuntimeException("Cannot call set more than once."); - } - } - - public static EventQualifierSerializer get() { - return Assert.notNull("Cannot call " + EventQualifierSerializer.class.getSimpleName() - + ".get() without first setting an instance.", instance); - } - - protected final Map serializers = new HashMap<>(); - - protected EventQualifierSerializer() { - } - - public String serialize(final Annotation qualifier) { - final AnnotationPropertyAccessor entry = serializers.get(qualifier.annotationType().getName()); - return SharedAnnotationSerializer.serialize(qualifier, entry); - } - - public String qualifierName(final String serializedQualifier) { - if (serializedQualifier.contains("(")) { - return serializedQualifier.substring(0, serializedQualifier.indexOf('(')); - } - else { - return serializedQualifier; - } - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/JsTypeEventObserver.java b/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/JsTypeEventObserver.java deleted file mode 100644 index 95392e22a85..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/JsTypeEventObserver.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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 org.jboss.errai.enterprise.client.cdi; - -import jsinterop.annotations.JsType; - -@JsType -public class JsTypeEventObserver { - - public void onEvent(T event) { - - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/WindowEventObservers.java b/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/WindowEventObservers.java deleted file mode 100644 index 2356a7476fd..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/WindowEventObservers.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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 org.jboss.errai.enterprise.client.cdi; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import jsinterop.annotations.JsType; - -@JsType -public class WindowEventObservers { - private final Map>> observers = new HashMap>>(); - - public static WindowEventObservers createOrGet() { - if (!windowEventObserversDefined()) { - setWindowEventObservers(new WindowEventObservers()); - } - return getWindowEventObservers(); - } - - public void add(final String eventType, final JsTypeEventObserver observer) { - if (!observers.containsKey(eventType)) { - observers.put(eventType, new ArrayList>()); - } - observers.get(eventType).add(observer); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - public void fireEvent(final String eventType, final Object evt) { - for (final JsTypeEventObserver observer : get(eventType)) { - observer.onEvent(evt); - } - } - - public JsTypeEventObserver[] get(final String eventType) { - if (!observers.containsKey(eventType)) { - return new JsTypeEventObserver[0]; - } - return observers.get(eventType).toArray(new JsTypeEventObserver[0]); - } - - private static native WindowEventObservers getWindowEventObservers() /*-{ - return $wnd.eventObservers; - }-*/; - - private static native void setWindowEventObservers(WindowEventObservers eo) /*-{ - $wnd.eventObservers = eo; - }-*/; - - private static native boolean windowEventObserversDefined() /*-{ - return !($wnd.eventObservers === undefined); - }-*/; - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/api/CDI.java b/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/api/CDI.java deleted file mode 100644 index e1c36521680..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/api/CDI.java +++ /dev/null @@ -1,284 +0,0 @@ -/* - * 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 org.jboss.errai.enterprise.client.cdi.api; - -import java.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Deque; -import java.util.HashMap; -import java.util.HashSet; -import java.util.IdentityHashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.jboss.errai.common.client.api.extension.InitVotes; -import org.jboss.errai.common.client.protocols.MessageParts; -import org.jboss.errai.enterprise.client.cdi.AbstractCDIEventCallback; -import org.jboss.errai.enterprise.client.cdi.CDICommands; -import org.jboss.errai.enterprise.client.cdi.CDIEventTypeLookup; -import org.jboss.errai.enterprise.client.cdi.CDIProtocol; -import org.jboss.errai.enterprise.client.cdi.EventQualifierSerializer; -import org.jboss.errai.enterprise.client.cdi.JsTypeEventObserver; -import org.jboss.errai.enterprise.client.cdi.WindowEventObservers; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * CDI client interface. - * - * @author Heiko Braun - * @author Christian Sadilek - * @author Mike Brock - */ -public class CDI { - public static final String CDI_SUBJECT_PREFIX = "cdi.event:"; - - public static final String CDI_SERVICE_SUBJECT_PREFIX = "cdi.event:"; - private static final String CLIENT_ALREADY_FIRED_RESOURCE = CDI_SERVICE_SUBJECT_PREFIX + "AlreadyFired"; - - private static final Set remoteEvents = new HashSet<>(); - private static boolean active = false; - - private static Map>> eventObservers = new HashMap<>(); - private static Set localOnlyObserverTypes = new HashSet<>(); - private static Map> lookupTable = Collections.emptyMap(); - - private static Logger logger = LoggerFactory.getLogger(CDI.class); - - public static String getSubjectNameByType(final String typeName) { - return CDI_SUBJECT_PREFIX + typeName; - } - - /** - * Should only be called by bootstrapper for testing purposes. - */ - public void __resetSubsystem() { - remoteEvents.clear(); - active = false; - eventObservers.clear(); - localOnlyObserverTypes.clear(); - lookupTable = Collections.emptyMap(); - } - - public void initLookupTable(final CDIEventTypeLookup lookup) { - lookupTable = lookup.getTypeLookupMap(); - } - - /** - * Return a list of string representations for the qualifiers. - * - * @param qualifiers - - * - * @return - */ - public static Set getQualifiersPart(final Annotation[] qualifiers) { - Set qualifiersPart = null; - if (qualifiers != null) { - for (final Annotation qualifier : qualifiers) { - if (qualifiersPart == null) - qualifiersPart = new HashSet<>(qualifiers.length); - - qualifiersPart.add(asString(qualifier)); - } - } - return qualifiersPart == null ? Collections.emptySet() : qualifiersPart; - - } - - private static String asString(final Annotation qualifier) { - return EventQualifierSerializer.get().serialize(qualifier); - } - - public static void fireEvent(final Object payload, final Annotation... qualifiers) { - fireEvent(false, payload, qualifiers); - } - - - public static void fireEvent(final boolean local, - final Object payload, - final Annotation... qualifiers) { - - if (payload == null) return; - - final Map messageMap = new HashMap<>(); - messageMap.put(MessageParts.CommandType.name(), CDICommands.CDIEvent.name()); - messageMap.put(CDIProtocol.BeanType.name(), payload.getClass().getName()); - messageMap.put(CDIProtocol.BeanReference.name(), payload); - messageMap.put(CDIProtocol.FromClient.name(), "1"); - - if (qualifiers != null && qualifiers.length > 0) { - messageMap.put(CDIProtocol.Qualifiers.name(), getQualifiersPart(qualifiers)); - } - - consumeEventFromMessage(CommandMessage.createWithParts(messageMap)); - } - - public static Subscription subscribeLocal(final String eventType, final AbstractCDIEventCallback callback) { - return subscribeLocal(eventType, callback, true); - } - - public static Subscription subscribeJsType(final String eventType, final JsTypeEventObserver callback) { - WindowEventObservers.createOrGet().add(eventType, callback); - return new Subscription() { - @Override - public void remove() { - // TODO can't unsubscribe per module atm. - } - }; - } - - private static Subscription subscribeLocal(final String eventType, final AbstractCDIEventCallback callback, - final boolean isLocalOnly) { - - if (!eventObservers.containsKey(eventType)) { - eventObservers.put(eventType, new ArrayList<>()); - } - - eventObservers.get(eventType).add(callback); - - if (isLocalOnly) { - localOnlyObserverTypes.add(eventType); - } - - return () -> unsubscribe(eventType, callback); - } - - public static Subscription subscribe(final String eventType, final AbstractCDIEventCallback callback) { - return subscribeLocal(eventType, callback, false); - } - - private static void unsubscribe(final String eventType, final AbstractCDIEventCallback callback) { - if (eventObservers.containsKey(eventType)) { - eventObservers.get(eventType).remove(callback); - - if (!localOnlyObserverTypes.contains(eventType)) { - if (eventObservers.get(eventType).isEmpty()) { - eventObservers.remove(eventType); - } - } - } - } - - - - public static void consumeEventFromMessage(final Message message) { - final String beanType = message.get(String.class, CDIProtocol.BeanType); - final Object beanRef = message.get(Object.class, CDIProtocol.BeanReference); - - final Set firedBeanTypes = new HashSet<>(); - final Deque beanTypeQueue = new LinkedList<>(); - beanTypeQueue.addLast(beanType); - firedBeanTypes.add(beanType); - while (!beanTypeQueue.isEmpty()) { - final String curType = beanTypeQueue.poll(); - WindowEventObservers.createOrGet().fireEvent(curType, beanRef); - _fireEvent(curType, message); - if (lookupTable.containsKey(curType)) { - for (final String superType : lookupTable.get(curType)) { - if (!firedBeanTypes.contains(superType)) { - beanTypeQueue.addLast(superType); - firedBeanTypes.add(superType); - } - } - } - } - } - - private static void _fireEvent(final String beanType, final Message message) { - if (eventObservers.containsKey(beanType)) { - for (final MessageCallback callback : new ArrayList(eventObservers.get(beanType))) { - try { - fireIfNotFired(callback, message); - } catch (final Exception e) { - final String potentialTarget = callbackOwnerClass(callback); - String actualTarget = potentialTarget.equalsIgnoreCase("undefined.undefined") ? "[unavailable]" : potentialTarget; - - throw new RuntimeException("CDI Event exception: " + message + " sent to " + actualTarget, e); - } - } - } - } - - private static native String callbackOwnerClass(final Object o) /*-{ - - var pkg, clazzName; - - for (var protoKey in o.__proto__) { - if (protoKey.startsWith("___clazz")) { - for (var clazzKey in o[protoKey]) { - if (clazzKey.startsWith("package")) { - pkg = o[protoKey][clazzKey]; - } - if (clazzKey.startsWith("compound")) { - clazzName = o[protoKey][clazzKey]; - } - } - } - } - return pkg + "." + clazzName; - }-*/; - - @SuppressWarnings("unchecked") - private static void fireIfNotFired(final MessageCallback callback, final Message message) { - if (!message.hasResource(CLIENT_ALREADY_FIRED_RESOURCE)) { - message.setResource(CLIENT_ALREADY_FIRED_RESOURCE, new IdentityHashMap<>()); - } - - if (!message.getResource(Map.class, CLIENT_ALREADY_FIRED_RESOURCE).containsKey(callback)) { - callback.callback(message); - message.getResource(Map.class, CLIENT_ALREADY_FIRED_RESOURCE).put(callback, ""); - } - } - - public static void addRemoteEventType(final String remoteEvent) { - remoteEvents.add(remoteEvent); - } - - - public static void addRemoteEventTypes(final String[] remoteEvent) { - for (final String s : remoteEvent) { - addRemoteEventType(s); - } - } - - public static void addPostInitTask(final Runnable runnable) { - InitVotes.registerOneTimeDependencyCallback(CDI.class, runnable); - } - - - public static void activate(final String... remoteTypes) { - if (!active) { - addRemoteEventTypes(remoteTypes); - active = true; - - logger.info("activated CDI eventing subsystem."); - InitVotes.voteFor(CDI.class); - } - } - - public static boolean isRemoteCommunicationEnabled() { - return false; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/api/CommandMessage.java b/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/api/CommandMessage.java deleted file mode 100644 index f1f63d5e92f..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/api/CommandMessage.java +++ /dev/null @@ -1,292 +0,0 @@ -/* - * 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 org.jboss.errai.enterprise.client.cdi.api; - -import java.util.HashMap; -import java.util.Map; - -import org.jboss.errai.common.client.api.Assert; -import org.jboss.errai.common.client.api.ErrorCallback; -import org.jboss.errai.common.client.api.ResourceProvider; -import org.jboss.errai.common.client.protocols.MessageParts; -import org.jboss.errai.common.client.types.TypeHandlerFactory; - -public class CommandMessage implements Message { - - transient final Map> providedParts; - final Map parts; - transient Map resources; - ErrorCallback errorsCall; - int routingFlags; - - /** - * Creates a new CommandMessage with no parts and no provided parts. - * - * @return a new instance of CommandMessage. - */ - public static CommandMessage create() { - return new CommandMessage(); - } - - public static CommandMessage createWithParts(final Map parts) { - return new CommandMessage(Assert.notNull(parts)); - } - - @SuppressWarnings("unchecked") - public static CommandMessage createWithPartsFromRawMap(final Map parts) { - return new CommandMessage(parts); - } - - public static CommandMessage createWithParts(final Map parts, final int flags) { - return new CommandMessage(Assert.notNull(parts), flags); - } - - public static CommandMessage createWithParts(final Map parts, final Map> provided) { - return new CommandMessage(parts, provided); - } - - CommandMessage() { - this.parts = new HashMap(); - this.providedParts = new HashMap>(5); - } - - private CommandMessage(final Map parts) { - this.parts = parts; - this.providedParts = new HashMap>(0); - } - - public CommandMessage(final Map parts, final int routingFlags) { - this.parts = parts; - this.routingFlags = routingFlags; - this.providedParts = new HashMap>(5); - } - - private CommandMessage(final Map parts, final Map> providers) { - this.parts = parts; - this.providedParts = providers; - } - - @Override - public String getCommandType() { - return (String) parts.get(MessageParts.CommandType.name()); - } - - @Override - public String getSubject() { - return String.valueOf(parts.get(MessageParts.ToSubject.name())); - } - - @Override - public Message toSubject(final String subject) { - parts.put(MessageParts.ToSubject.name(), subject); - return this; - } - - @Override - public Message command(final Enum type) { - parts.put(MessageParts.CommandType.name(), type.name()); - return this; - } - - @Override - public Message command(final String type) { - parts.put(MessageParts.CommandType.name(), type); - return this; - } - - @Override - public Message set(final Enum part, final Object value) { - return set(part.name(), value); - } - - @Override - public Message set(final String part, final Object value) { - parts.put(part, value); - return this; - } - - @Override - public Message setProvidedPart(final String part, final ResourceProvider provider) { - providedParts.put(part, provider); - return this; - } - - @Override - public Message setProvidedPart(final Enum part, final ResourceProvider provider) { - return setProvidedPart(part.name(), provider); - } - - @Override - public void remove(final String part) { - parts.remove(part); - } - - @Override - public void remove(final Enum part) { - parts.remove(part.name()); - } - - @Override - public Message copy(final Enum part, final Message message) { - set(part, message.get(Object.class, part)); - return this; - } - - @Override - public Message copy(final String part, final Message message) { - set(part, message.get(Object.class, part)); - return this; - } - - @Override - public T getValue(Class type) { - return get(type, MessageParts.Value); - } - - @Override - @SuppressWarnings({ "UnusedDeclaration" }) - public T get(final Class type, final Enum part) { - return get(type, part.toString()); - } - - @Override - @SuppressWarnings({ "UnusedDeclaration" }) - public T get(final Class type, final String part) { - final Object value = parts.get(part); - return value == null ? null : TypeHandlerFactory.convert(value.getClass(), type, value); - } - - @Override - public boolean hasPart(final Enum part) { - return hasPart(part.name()); - } - - @Override - public boolean hasPart(final String part) { - return parts.containsKey(part); - } - - @Override - public Map getParts() { - return parts; - } - - @Override - public Map> getProvidedParts() { - return providedParts; - } - - @Override - public Message setParts(final Map parts) { - parts.clear(); - parts.putAll(parts); - return this; - } - - @Override - public Message addAllParts(final Map parts) { - this.parts.putAll(parts); - return this; - } - - @Override - public Message addAllProvidedParts(final Map> parts) { - this.providedParts.putAll(parts); - return this; - } - - @Override - public Message setResource(final String key, final Object res) { - if (this.resources == null) - this.resources = new HashMap(); - this.resources.put(key, res); - return this; - } - - @Override - @SuppressWarnings("unchecked") - public T getResource(final Class type, final String key) { - return (T) (this.resources == null ? null : this.resources.get(key)); - } - - @Override - public Message copyResource(final String key, final Message copyFrom) { - if (!copyFrom.hasResource(key)) { - throw new RuntimeException("Cannot copy resource '" + key + "': no such resource."); - } - setResource(key, copyFrom.getResource(Object.class, key)); - return this; - } - - @Override - public Message errorsCall(final ErrorCallback callback) { - if (this.errorsCall != null) { - throw new RuntimeException("An ErrorCallback is already registered"); - } - this.errorsCall = callback; - return this; - } - - @Override - public ErrorCallback getErrorCallback() { - return errorsCall; - } - - @Override - public boolean hasResource(final String key) { - return this.resources != null && this.resources.containsKey(key); - } - - @Override - public void addResources(final Map resources) { - if (this.resources == null) { - this.resources = new HashMap(resources); - } - else { - this.resources.putAll(resources); - } - } - - @Override - public void commit() { - if (!providedParts.isEmpty()) { - for (final Map.Entry> entry : providedParts.entrySet()) - set(entry.getKey(), entry.getValue().get()); - } - } - - @Override - public String toString() { - return buildDescription(); - } - - private String buildDescription() { - final StringBuilder append = new StringBuilder(); - boolean f = false; - for (final Map.Entry entry : parts.entrySet()) { - if (f) - append.append(", "); - append.append(entry.getKey()).append("=").append(String.valueOf(entry.getValue())); - f = true; - } - return append.toString(); - } -} \ No newline at end of file diff --git a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/api/Conversational.java b/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/api/Conversational.java deleted file mode 100644 index f6743ad1d02..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/api/Conversational.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 org.jboss.errai.enterprise.client.cdi.api; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -/** - * Identifies an annotated event type is a conversational type. Meaning, that the annotated event must not result - * in a propagation to other event observation methods outside the current session context. - *

- * The annotated class must also be annotated with {@link org.jboss.errai.common.client.api.annotations.Portable} in - * addition to being marked conversational, in order for the event to be transmittable across buses. - *

- * Events marked conversational are always conversational and may not never be used for broadcasting. - *

- * Unlike {@code @Portable}, this annotation is not inherited by subclasses. Each conversational event type must be - * explicitly marked with this annotation. - * - * @author Mike Brock - */ -@Target({ElementType.TYPE}) -@Retention(RUNTIME) -@Documented -public @interface Conversational {} diff --git a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/api/Message.java b/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/api/Message.java deleted file mode 100644 index 5ce883b84a0..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/api/Message.java +++ /dev/null @@ -1,321 +0,0 @@ -/* - * 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 org.jboss.errai.enterprise.client.cdi.api; - -import java.util.Map; - -import org.jboss.errai.common.client.api.ErrorCallback; -import org.jboss.errai.common.client.api.ResourceProvider; - -public interface Message { - - /** - * Sets the subject of this message, which is the intended recipient, and returns the message. - * - * @param subject - * the intended recipient of the message. - * @return this message. - */ - public Message toSubject(String subject); - - /** - * Returns the message's subject. - * - * @return this message's subject (its intended recipient). - */ - public String getSubject(); - - /** - * Sets the command type for this message. Command is an optional extension for creating services that can respond to - * different specific commands. - * - * @param type - * String representation of a command type. - * @return this message. - */ - public Message command(String type); - - /** - * Set the command type for this message. Command is an optional extension for creating services that can respond to - * different specific commands. - * - * @param type - * Enum representation of a command type. - * @return this message. - */ - public Message command(Enum type); - - /** - * Returns the command type for this message as a String. - * - * @return the command type. - */ - public String getCommandType(); - - /** - * Sets a Message part to the specified value. - * - * @param part - * The String name of the message part. - * @param value - * The value to set the part to. - * @return this message. - */ - public Message set(String part, Object value); - - /** - * Sets a Message part to the specified value. - * - * @param part - * The Enum representation of the message part. - * @param value - * the value to set the part to. - * @return this message. - */ - public Message set(Enum part, Object value); - - /** - * Adds or replaces a message part whose value is recomputed every time the message is sent. - * - * @param part - * The name of the message part. - * @param provider - * a callback that provides the value of the message part on demand. Will be called every time this message - * is sent. - * @return this message. - */ - public Message setProvidedPart(String part, ResourceProvider provider); - - /** - * Adds or replaces a message part whose value is recomputed every time the message is sent. - * - * @param part - * The Enum representation of the message part. - * @param provider - * a callback that provides the value of the message part on demand. Will be called every time this message - * is sent. - * @return this message. - */ - public Message setProvidedPart(Enum part, ResourceProvider provider); - - /** - * Checks if message contains the specified part. - * - * @param part - * String part to check for. - * @return true if message contains {@code part}. - */ - public boolean hasPart(String part); - - /** - * Checks if message contains the specified part. - * - * @param part - * Enum part to check for. - * @return true if message contains {@code part}. - */ - public boolean hasPart(Enum part); - - /** - * Removes specified part from the message. - * - * @param part - * the part to remove. - */ - public void remove(String part); - - /** - * Removes specified part from the message. - * - * @param part - * the part to remove. - */ - public void remove(Enum part); - - /** - * Copies a part of this message to another message. - * - * @param part - * the part of this message to copy. - * @param m - * the message to copy the part to. Must not be null. - * @return this message - */ - public Message copy(String part, Message m); - - /** - * Copies a part of this message to another message. - * - * @param part - * the part of this message to copy. - * @param m - * the message to copy the part to. Must not be null. - * @return this message - */ - public Message copy(Enum part, Message m); - - /** - * Sets the message to contain the specified parts. This overwrites any - * existing message contents. - *

- * Implementations may or may not create a defensive copy of the given map. - * Check their documentation to be sure. - * - * @param parts - * Parts to be used in the message. Must not be null. - * @return this message - */ - public Message setParts(Map parts); - - /** - * Copies in a set of message parts from the provided map. - * - * @param parts - * Parts to be added to the message. Must not be null. - * @return this message - */ - public Message addAllParts(Map parts); - - /** - * Copies in a set of provided message parts from the provided maps - * - * @param provided - * provided parts to be added to the message - * @return this message - */ - public Message addAllProvidedParts(Map> provided); - - /** - * Returns a Map of all the specified parts. - * - * @return a Map of the message parts. - */ - public Map getParts(); - - /** - * Returns a Map of all provided parts. - * - * @return a Map of the provided message parts. - */ - public Map> getProvidedParts(); - - /** - * Adds the Map of resources to the message. - * - * @param resources - * Map of resource - */ - public void addResources(Map resources); - - /** - * Sets a transient resource. A resource is not transmitted beyond the current bus scope. It can be used for managing - * the lifecycle of a message within a bus. - * - * @param key - * Name of resource. - * @param res - * Instance of resource. - * @return this message - */ - public Message setResource(String key, Object res); - - /** - * Obtains a transient resource based on the specified key. - * - * @param type - * type of resource. - * @param key - * the name of the resource - * @return Instance of resource. - */ - public T getResource(Class type, String key); - - /** - * Returns true if the specified transient resource is present. - * - * @param key - * Name of resource. - * @return boolean value indicating if the specified resource is present in the message. - */ - public boolean hasResource(String key); - - /** - * Copies a transient resource to this message from the specified message. - * - * @param key Name of resource. - * @param m Message to copy from. - * @return this message. - */ - public Message copyResource(String key, Message m); - - /** - * Sets the error callback for this message. - * - * @param callback error callback. - * @return this message. - */ - public Message errorsCall(ErrorCallback callback); - - /** - * Gets the error callback for this message. - * - * @return the error callback - */ - public ErrorCallback getErrorCallback(); - - public T getValue(Class type); - - /** - * Gets the specified message part in the specified type. A ClassCastException is thrown if the value cannot - * be coerced to the specified type. - * - * @param type - * Type to be returned. - * @param part - * Message part. - * @param - * Type to be returned. - * @return Value in the specified type. - */ - public T get(Class type, String part); - - /** - * Gets the specified message part in the specified type. A ClassCastException is thrown if the value cannot - * be coerced to the specified type. - * - * @param type - * Type to be returned. - * @param part - * Message part. - * @param - * Type to be returned. - * @return Value in the specified type. - */ - public T get(Class type, Enum part); - - /** - * Commits the message in its current structure. After this method is called, there is no guarantee that any changes - * in the message will be communicated across the bus. In fact, modifying the message after calling commit() may - * create a corrupt payload. In theory, you should never call this method. It's called by the message bus immediately - * before transmission. - */ - public void commit(); -} \ No newline at end of file diff --git a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/api/MessageCallback.java b/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/api/MessageCallback.java deleted file mode 100644 index 82f35c18479..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/api/MessageCallback.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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 org.jboss.errai.enterprise.client.cdi.api; - - -public interface MessageCallback { - - /** - * Called by the Message Bus every time it processes a message with the - * subject this callback is registered for. - * - * @param message - * The message on the bus. Avoid making changes to this object, - * because it will continue to be reused by the framework and the - * same Message instance will be passed to other callbacks. - */ - public void callback(Message message); -} \ No newline at end of file diff --git a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/api/Subscription.java b/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/api/Subscription.java deleted file mode 100644 index 797340092fd..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/client/cdi/api/Subscription.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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 org.jboss.errai.enterprise.client.cdi.api; - -/** - * @author Mike Brock - */ -public interface Subscription { - /** - * Remove the subscription. - */ - public void remove(); -} \ No newline at end of file diff --git a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/rebind/NonGwtEventQualifierSerializerGenerator.java b/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/rebind/NonGwtEventQualifierSerializerGenerator.java deleted file mode 100644 index 2f89576b441..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-cdi/errai-cdi-shared/src/main/java/org/jboss/errai/enterprise/rebind/NonGwtEventQualifierSerializerGenerator.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * 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 org.jboss.errai.enterprise.rebind; - -import java.util.Collection; -import java.util.Optional; -import java.util.function.Function; - -import org.jboss.errai.codegen.Parameter; -import org.jboss.errai.codegen.builder.ClassStructureBuilder; -import org.jboss.errai.codegen.builder.ConstructorBlockBuilder; -import org.jboss.errai.codegen.builder.ContextualStatementBuilder; -import org.jboss.errai.codegen.builder.impl.ClassBuilder; -import org.jboss.errai.codegen.builder.impl.ObjectBuilder; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaMethod; -import org.jboss.errai.codegen.util.CDIAnnotationUtils; -import org.jboss.errai.codegen.util.ClassChangeUtil; -import org.jboss.errai.common.client.api.Assert; -import org.jboss.errai.common.client.util.AnnotationPropertyAccessorBuilder; -import org.jboss.errai.common.client.util.SharedAnnotationSerializer; -import org.jboss.errai.enterprise.client.cdi.EventQualifierSerializer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static org.jboss.errai.codegen.builder.impl.ObjectBuilder.newInstanceOf; -import static org.jboss.errai.codegen.util.Stmt.castTo; -import static org.jboss.errai.codegen.util.Stmt.invokeStatic; -import static org.jboss.errai.codegen.util.Stmt.loadVariable; -import static org.jboss.errai.enterprise.client.cdi.EventQualifierSerializer.SERIALIZER_CLASS_NAME; -import static org.jboss.errai.enterprise.client.cdi.EventQualifierSerializer.SERIALIZER_PACKAGE_NAME; - -/** - * - * @author Max Barkley - */ -public class NonGwtEventQualifierSerializerGenerator { - - private static final Logger logger = LoggerFactory.getLogger(NonGwtEventQualifierSerializerGenerator.class); - - private NonGwtEventQualifierSerializerGenerator() {} - - @SuppressWarnings("unchecked") - public static Class generateAndLoad() { - logger.info("Generating source for {}.{}...", SERIALIZER_PACKAGE_NAME, SERIALIZER_CLASS_NAME); - final String source = generateSource(CDIAnnotationUtils.getQualifiers()); - logger.info("Successfully generated source for {}.{}", SERIALIZER_PACKAGE_NAME, SERIALIZER_CLASS_NAME); - - logger.info("Attempting to compile and load {}.{}", SERIALIZER_PACKAGE_NAME, SERIALIZER_CLASS_NAME); - return (Class) ClassChangeUtil - .compileAndLoadFromSource(SERIALIZER_PACKAGE_NAME, SERIALIZER_CLASS_NAME, source); - } - - static String generateSource(final Iterable qualifiers) { - final ClassStructureBuilder body = ClassBuilder - .define(SERIALIZER_PACKAGE_NAME + "." + SERIALIZER_CLASS_NAME, EventQualifierSerializer.class) - .publicScope().body(); - final ConstructorBlockBuilder ctor = body.publicConstructor(); - - for (final MetaClass qual : qualifiers) { - final Collection bindingAttributes = CDIAnnotationUtils.getAnnotationAttributes(qual); - if (!bindingAttributes.isEmpty()) { - ctor.append(loadVariable("serializers").invoke("put", qual.getFullyQualifiedName(), generateEntryStatement(qual, bindingAttributes))); - } - } - ctor.finish(); - - return body.toJavaString(); - } - - private static ContextualStatementBuilder generateEntryStatement(final MetaClass qual, - final Collection bindingAttributes) { - ContextualStatementBuilder entryStmt = invokeStatic(AnnotationPropertyAccessorBuilder.class, "create"); - - for (final MetaMethod attr : bindingAttributes) { - entryStmt = entryStmt.invoke("with", attr.getName(), anonymousAttributeAccessorFor(attr)); - } - - entryStmt = entryStmt.invoke("build"); - return entryStmt; - } - - private static ObjectBuilder anonymousAttributeAccessorFor(final MetaMethod attr) { - return newInstanceOf(Function.class).extend() - .publicOverridesMethod("apply", Parameter.finalOf(Object.class, "anno")) - .append(invokeStatic(SharedAnnotationSerializer.class, "stringify", - castTo(attr.getDeclaringClass(), loadVariable("anno")).invoke(attr)) - .returnValue()) - .finish().finish(); - } - - public static void loadAndSetEventQualifierSerializer() { - logger.info("Attempting to load {}.{}", SERIALIZER_PACKAGE_NAME, SERIALIZER_CLASS_NAME); - final Optional> loadedImpl = ClassChangeUtil.loadClassIfPresent( - SERIALIZER_PACKAGE_NAME, - SERIALIZER_CLASS_NAME); - - if (loadedImpl.isPresent()) { - logger.info("Successfully loaded {}.{}", SERIALIZER_PACKAGE_NAME, SERIALIZER_CLASS_NAME); - final Class clazz = loadedImpl.get(); - instantiateAndSetEventQualifierSerializer(clazz); - } - else { - logger.warn("No {}.{} found on the classpath. Attempting to generate and load.", - SERIALIZER_PACKAGE_NAME, SERIALIZER_CLASS_NAME); - final Class clazz; - try { - clazz = Assert.notNull(generateAndLoad()); - } catch (final Throwable t) { - throw new RuntimeException("Could not generate " + EventQualifierSerializer.SERIALIZER_CLASS_NAME, t); - } - - logger.info("Successfully generated and loaded {}.{}", SERIALIZER_PACKAGE_NAME, SERIALIZER_CLASS_NAME); - instantiateAndSetEventQualifierSerializer(clazz); - } - } - - public static void instantiateAndSetEventQualifierSerializer(final Class clazz) { - try { - EventQualifierSerializer.set(clazz.asSubclass(EventQualifierSerializer.class).newInstance()); - } catch (InstantiationException | IllegalAccessException e) { - throw new RuntimeException("Could not instantiate " + SERIALIZER_PACKAGE_NAME + "." - + SERIALIZER_CLASS_NAME + " with default constructor.", e); - } catch (final ClassCastException e) { - throw new RuntimeException(SERIALIZER_PACKAGE_NAME + "." + SERIALIZER_CLASS_NAME - + " must be a subclass of " + EventQualifierSerializer.class.getName(), e); - } - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-cdi/pom.xml b/packages/serverless-workflow-diagram-editor/errai-cdi/pom.xml deleted file mode 100644 index a3d57b7295f..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-cdi/pom.xml +++ /dev/null @@ -1,113 +0,0 @@ - - - 4.0.0 - Errai::CDI - cdi-integration-parent - pom - - http://jboss.org/errai/errai - - - org.kie.kogito.stunner.serverless.editor - stunner-editors-parent - ${revision} - ../pom.xml - - - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - - - CDI Integration for Errai - - - - - Mike Brock - - - Christian Sadilek - - - Heiko Braun - - - Jonathan Fuerth - http://jonathan.fuerth.ca/ - JBoss, a division of Red Hat - http://community.jboss.org/ - - - - - scm:git:git@github.com:errai/errai-cdi.git - scm:git:git@github.com:errai/errai-cdi.git - scm:git:git@github.com:errai/errai-cdi.git - - - - JBoss, a division of Red Hat - http://www.jboss.org - - - - errai-cdi-client - errai-cdi-shared - - - - - - maven-source-plugin - - - attach-sources - - jar - - - - - target/classes - - - - - - - - integration-test - - - - maven-failsafe-plugin - - false - false - - -Xmx1500m ${argLine} -Dgwt.args='-testBeginTimeout 5 ${gwtArgs}' -Derrai.hosted_mode_testing=true - -Derrai.ioc.experimental.infer_dependent_by_reachability=true - - - - log4j.output.dir - ${project.build.directory} - - - - - - - - - - diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/pom.xml b/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/pom.xml deleted file mode 100644 index e91d1709550..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/pom.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - - org.kie.kogito.stunner.serverless.editor - stunner-editors-parent - ${revision} - - 4.0.0 - - errai-codegen-gwt - Errai::Codegen::GWT - - - - org.kie.kogito.stunner.serverless.editor - errai-codegen - - - org.kie.kogito.stunner.serverless.editor - errai-codegen - test-jar - test - - - javax.enterprise - cdi-api - provided - - - - org.gwtproject - gwt-user - - provided - - - org.gwtproject - gwt-dev - - provided - - - org.eclipse.jetty - jetty-annotations - - - - - - - - maven-failsafe-plugin - - - ${basedir}/test-classes/ - ${basedir}/src/test/java/ - ${basedir}/src/test/resources/ - - false - - - - java.io.tmpdir - ${project.build.directory} - - - log4j.output.dir - ${project.build.directory} - - - - - - - - diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTClass.java b/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTClass.java deleted file mode 100644 index 3daf139407b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTClass.java +++ /dev/null @@ -1,614 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta.impl.gwt; - -import java.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.stream.Stream; - -import com.google.common.collect.Lists; -import com.google.gwt.core.ext.typeinfo.JArrayType; -import com.google.gwt.core.ext.typeinfo.JClassType; -import com.google.gwt.core.ext.typeinfo.JConstructor; -import com.google.gwt.core.ext.typeinfo.JEnumType; -import com.google.gwt.core.ext.typeinfo.JField; -import com.google.gwt.core.ext.typeinfo.JGenericType; -import com.google.gwt.core.ext.typeinfo.JMethod; -import com.google.gwt.core.ext.typeinfo.JParameter; -import com.google.gwt.core.ext.typeinfo.JParameterizedType; -import com.google.gwt.core.ext.typeinfo.JType; -import com.google.gwt.core.ext.typeinfo.NotFoundException; -import com.google.gwt.core.ext.typeinfo.TypeOracle; -import org.jboss.errai.codegen.DefModifiers; -import org.jboss.errai.codegen.Parameter; -import org.jboss.errai.codegen.builder.impl.Scope; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.meta.MetaConstructor; -import org.jboss.errai.codegen.meta.MetaField; -import org.jboss.errai.codegen.meta.MetaMethod; -import org.jboss.errai.codegen.meta.MetaTypeVariable; -import org.jboss.errai.codegen.meta.impl.AbstractMetaClass; -import org.jboss.errai.codegen.util.GWTPrivateMemberAccessor; -import org.jboss.errai.codegen.util.GenUtil; -import org.jboss.errai.codegen.util.PrivateAccessUtil; -import org.jboss.errai.common.rebind.CacheStore; -import org.jboss.errai.common.rebind.CacheUtil; -import org.jboss.errai.reflections.scanners.AbstractScanner; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public class GWTClass extends AbstractMetaClass { - protected final Annotation[] annotations; - protected TypeOracle oracle; - private String fqcn; - - static { - GenUtil.addClassAlias(GWTClass.class); - PrivateAccessUtil.registerPrivateMemberAccessor("jsni", new GWTPrivateMemberAccessor()); - } - - protected GWTClass(final TypeOracle oracle, final JType classType, final boolean erased) { - super(classType); - this.oracle = oracle; - - final JClassType classOrInterface = classType.isClassOrInterface(); - if (classOrInterface != null) { - annotations = classOrInterface.getAnnotations(); - } - else { - annotations = new Annotation[0]; - } - - if (classType.isTypeParameter() != null || classType.isWildcard() != null) { - throw new IllegalArgumentException("Cannot represent \"" + classType - + "\" as a class. Try a different meta type such as GWTWildcardType or GWTTypeVariable."); - } - - final JParameterizedType parameterizedType = classType.isParameterized(); - if (!erased) { - if (parameterizedType != null) { - super.parameterizedType = new GWTParameterizedType(oracle, parameterizedType); - } - } - } - - - public static class GWTClassCache implements CacheStore { - private final Map reloadableClasses = new ConcurrentHashMap<>(); - - // Classes in .jar files can't change between refreshes so we can hold on to them - private final Map classesInJar = new ConcurrentHashMap<>(); - - @Override - public void clear() { - reloadableClasses.clear(); - } - - public void put(final String name, final MetaClass clazz) { - if (AbstractScanner.isInJar(name) && !name.contains("<")) { - classesInJar.put(name, clazz); - } - else { - reloadableClasses.put(name, clazz); - } - } - - public MetaClass get(final String name) { - final MetaClass clazz = classesInJar.get(name); - if (clazz != null) { - if (AbstractScanner.isInJar(name)) { - return clazz; - } - else { - classesInJar.remove(name); - return null; - } - } - else { - return reloadableClasses.get(name); - } - } - } - - final static GWTClassCache cache = CacheUtil.getCache(GWTClassCache.class); - - public static MetaClass newInstance(final TypeOracle oracle, final JType type) { - MetaClass clazz = cache.get(type.getParameterizedQualifiedSourceName()); - if (clazz == null) { - clazz = newUncachedInstance(oracle, type); - cache.put(type.getParameterizedQualifiedSourceName(), clazz); - } - - return clazz; - } - - public static MetaClass newInstance(final TypeOracle oracle, final String type) { - try { - return newUncachedInstance(oracle, oracle.getType(type)); - } - catch (final NotFoundException e) { - return null; - } - } - - public static MetaClass newUncachedInstance(final TypeOracle oracle, final JType type) { - return new GWTClass(oracle, type, false); - } - - public static MetaClass newUncachedInstance(final TypeOracle oracle, final JType type, final boolean erased) { - return new GWTClass(oracle, type, erased); - } - - public static MetaClass[] fromClassArray(final TypeOracle oracle, final JClassType[] classes) { - return Arrays.stream(classes).map(c -> newInstance(oracle, c)).toArray(s -> new MetaClass[s]); - } - - public static Class[] jParmToClass(final JParameter[] parms) throws ClassNotFoundException { - return Arrays.stream(parms).map(p -> getPrimitiveOrClass(p)).toArray(s -> new Class[s]); - } - - public static Class getPrimitiveOrClass(final JParameter parm) { - final JType type = parm.getType(); - final String name = - type.isArray() != null ? type.getJNISignature().replace("/", ".") : type.getQualifiedSourceName(); - - if (parm.getType().isPrimitive() != null) { - final char sig = parm.getType().isPrimitive().getJNISignature().charAt(0); - - switch (sig) { - case 'Z': - return boolean.class; - case 'B': - return byte.class; - case 'C': - return char.class; - case 'D': - return double.class; - case 'F': - return float.class; - case 'I': - return int.class; - case 'J': - return long.class; - case 'S': - return short.class; - case 'V': - return void.class; - default: - return null; - } - } - else { - try { - return Class.forName(name, false, Thread.currentThread().getContextClassLoader()); - } - catch (final ClassNotFoundException e) { - throw new RuntimeException(e); - } - } - } - - @Override - public String getName() { - return getEnclosedMetaObject().getSimpleSourceName(); - } - - @Override - public String getFullyQualifiedName() { - if (fqcn != null) { - return fqcn; - } - - if (isArray()) { - if (getOuterComponentType().isPrimitive()) { - fqcn = getInternalName(); - } - else { - fqcn = getInternalName().replace('/', '.'); - } - } - else { - fqcn = getEnclosedMetaObject().getQualifiedBinaryName(); - } - return fqcn; - } - - @Override - public String getCanonicalName() { - return getEnclosedMetaObject().getQualifiedSourceName(); - } - - @Override - public String getInternalName() { - return getEnclosedMetaObject().getJNISignature(); - } - - private String _packageName = null; - @Override - public String getPackageName() { - if (_packageName != null) { - return _packageName; - } - - _packageName = getEnclosedMetaObject().isClassOrInterface().getPackage().getName(); - return _packageName; - } - - private static MetaMethod[] fromMethodArray(final TypeOracle oracle, final JMethod[] methods) { - return Arrays.stream(methods).map(m -> new GWTMethod(oracle, m)).toArray(s -> new MetaMethod[s]); - } - - private List getSpecialTypeMethods() { - final List meths = new ArrayList<>(); - final JEnumType type = getEnclosedMetaObject().isEnum(); - - if (type != null) { - meths.add(new GWTSpecialMethod(this, DefModifiers.none(), Scope.Public, String.class, "name")); - meths.add(new GWTSpecialMethod(this, DefModifiers.none(), Scope.Public, Enum.class, "valueOf", Parameter.of( - String.class, "p").getMetaParameter())); - meths.add(new GWTSpecialMethod(this, DefModifiers.none(), Scope.Public, Enum[].class, "values")); - } - - return meths; - } - - // TODO report this to be fixed in GWT: getClass() in java.lang.Object is reported as non-final method. - private static final List overrideMethods = - Arrays.asList(MetaClassFactory.get(Object.class).getMethods()); - - private MetaMethod[] _methodsCache = null; - - @Override - public MetaMethod[] getMethods() { - if (_methodsCache != null) { - return _methodsCache; - } - - final Set meths = new LinkedHashSet<>(); - meths.addAll(getSpecialTypeMethods()); - - JClassType type = getEnclosedMetaObject().isClassOrInterface(); - if (type == null) { - return null; - } - - final Set processedMethods = new HashSet<>(); - do { - for (final JMethod jMethod : type.getMethods()) { - final GWTMethod gwtMethod = new GWTMethod(oracle, jMethod); - final String readableMethodDecl = GenUtil.getMethodString(gwtMethod); - if (!jMethod.isPrivate() && !processedMethods.contains(readableMethodDecl)) { - meths.add(gwtMethod); - processedMethods.add(readableMethodDecl); - } - } - - for (final JClassType interfaceType : type.getImplementedInterfaces()) { - for (final MetaMethod ifaceMethod : Arrays.asList(GWTClass.newInstance(oracle, interfaceType).getMethods())) { - final String readableMethodDecl = GenUtil.getMethodString(ifaceMethod); - if (!processedMethods.contains(readableMethodDecl)) { - meths.add(ifaceMethod); - processedMethods.add(readableMethodDecl); - } - } - } - } - while ((type = type.getSuperclass()) != null && !type.getQualifiedSourceName().equals("java.lang.Object")); - meths.addAll(overrideMethods); - _methodsCache = meths.toArray(new MetaMethod[meths.size()]); - - return _methodsCache; - } - - @Override - public MetaMethod[] getDeclaredMethods() { - final JClassType type = getEnclosedMetaObject().isClassOrInterface(); - if (type == null) { - return null; - } - - return fromMethodArray(oracle, type.getMethods()); - } - - @Override - public MetaClass getErased() { - if (getParameterizedType() == null) { - return this; - } - else { - return new GWTClass(oracle, getEnclosedMetaObject().getErasedType(), true); - } - } - - @Override - public MetaField[] getFields() { - final List fields = Lists.newArrayList(); - - JClassType type = getEnclosedMetaObject().isClass(); - while (type != null) { - for (final JField field : type.getFields()) { - // In GWT 2.7 java.lang.Object contains two public fields castableTypeMap and typeMarker that we don't want. - if (field.isPublic() && !field.getEnclosingType().getQualifiedSourceName().equals("java.lang.Object")) { - fields.add(new GWTField(oracle, field)); - } - } - type = type.getSuperclass(); - } - - return fields.toArray(new MetaField[fields.size()]); - } - - @Override - public MetaField[] getDeclaredFields() { - final JClassType type = getEnclosedMetaObject().isClass(); - if (type != null) { - return Arrays.stream(type.getFields()).map(f -> new GWTField(oracle, f)).toArray(s -> new MetaField[s]); - } - - return new MetaField[0]; - } - - @Override - public MetaField getField(final String name) { - JClassType type = getEnclosedMetaObject().isClassOrInterface(); - if (type == null) { - if ("length".equals(name) && getEnclosedMetaObject().isArray() != null) { - return new MetaField.ArrayLengthMetaField(this); - } - return null; - } - - JField field = type.findField(name); - while ((field == null || (field != null && !field.isPublic())) && - (type = type.getSuperclass()) != null && !type.getQualifiedSourceName().equals("java.lang.Object")) { - field = type.findField(name); - - for (final JClassType interfaceType : type.getImplementedInterfaces()) { - field = interfaceType.findField(name); - } - } - - if (field == null) { - throw new RuntimeException("no such field: " + name + " in class: " + this); - } - - return new GWTField(oracle, field); - } - - @Override - public MetaField getDeclaredField(final String name) { - final JClassType type = getEnclosedMetaObject().isClassOrInterface(); - if (type == null) { - if ("length".equals(name) && getEnclosedMetaObject().isArray() != null) { - return new MetaField.ArrayLengthMetaField(this); - } - return null; - } - - final JField field = type.findField(name); - - if (field == null) { - return null; - } - - return new GWTField(oracle, field); - } - - private static MetaConstructor[] fromMethodArray(final TypeOracle oracle, final Stream constructors) { - return constructors.map(c -> new GWTConstructor(oracle, c)).toArray(s -> new MetaConstructor[s]); - } - - @Override - public MetaConstructor[] getConstructors() { - final JClassType type = getEnclosedMetaObject().isClassOrInterface(); - if (type == null) { - return null; - } - - return fromMethodArray(oracle, - Arrays - .stream(type.getConstructors()) - .filter(ctor -> ctor.isPublic())); - } - - @Override - public MetaConstructor[] getDeclaredConstructors() { - final JClassType type = getEnclosedMetaObject().isClassOrInterface(); - if (type == null) { - return null; - } - - return fromMethodArray(oracle, Arrays.stream(type.getConstructors())); - } - - @Override - public MetaClass[] getDeclaredClasses() { - final JClassType[] nestedTypes = getEnclosedMetaObject().isClassOrInterface().getNestedTypes(); - final MetaClass[] declaredClasses = new MetaClass[nestedTypes.length]; - int i = 0; - for (final JClassType type : nestedTypes) { - declaredClasses[i++] = GWTClass.newInstance(oracle, type); - } - return declaredClasses; - } - - private MetaClass[] _intefacesCache = null; - - @Override - public MetaClass[] getInterfaces() { - if (_intefacesCache != null) { - return _intefacesCache; - } - - final JClassType jClassType = getEnclosedMetaObject().isClassOrInterface(); - if (jClassType == null) - return new MetaClass[0]; - - return _intefacesCache = Arrays.stream(jClassType.getImplementedInterfaces()) - .map(i -> new GWTClass(oracle, i, false)).toArray(s -> new MetaClass[s]); - } - - @Override - public boolean isArray() { - return getEnclosedMetaObject().isArray() != null; - } - - @Override - public MetaClass getSuperClass() { - JClassType type = getEnclosedMetaObject().isClassOrInterface(); - if (type == null) { - return null; - } - - type = type.getSuperclass(); - - if (type == null) { - return null; - } - - return newInstance(oracle, type); - } - - @Override - public MetaClass getComponentType() { - final JArrayType type = getEnclosedMetaObject().isArray(); - if (type == null) { - return null; - } - return newUncachedInstance(oracle, type.getComponentType()); - } - - @Override - public Annotation[] getAnnotations() { - return annotations; - } - - @Override - public MetaTypeVariable[] getTypeParameters() { - final JGenericType genericType; - - if (getEnclosedMetaObject().isGenericType() != null) { - genericType = getEnclosedMetaObject().isGenericType(); - } - else if (getEnclosedMetaObject().isParameterized() != null) { - genericType = getEnclosedMetaObject().isParameterized().getBaseType(); - } - else if (getEnclosedMetaObject().isRawType() != null) { - genericType = getEnclosedMetaObject().isRawType().getGenericType(); - } - else { - return new MetaTypeVariable[0]; - } - - return Arrays.stream(genericType.getTypeParameters()) - .map(p -> new GWTTypeVariable(oracle, p)).toArray(s -> new MetaTypeVariable[s]); - } - - @Override - public boolean isVoid() { - return getEnclosedMetaObject().getSimpleSourceName().equals("void"); - } - - @Override - public boolean isPrimitive() { - return getEnclosedMetaObject().isPrimitive() != null; - } - - @Override - public boolean isInterface() { - return getEnclosedMetaObject().isInterface() != null; - } - - @Override - public boolean isAbstract() { - return getEnclosedMetaObject().isClass() != null && getEnclosedMetaObject().isClass().isAbstract(); - } - - @Override - public boolean isEnum() { - return getEnclosedMetaObject().isEnum() != null; - } - - @Override - public boolean isAnnotation() { - return getEnclosedMetaObject().isAnnotation() != null; - } - - @Override - public boolean isPublic() { - return getEnclosedMetaObject().isClassOrInterface() != null && - getEnclosedMetaObject().isClassOrInterface().isPublic(); - } - - @Override - public boolean isPrivate() { - return getEnclosedMetaObject().isClassOrInterface() != null && - getEnclosedMetaObject().isClassOrInterface().isPrivate(); - } - - @Override - public boolean isProtected() { - return getEnclosedMetaObject().isClassOrInterface() != null && - getEnclosedMetaObject().isClassOrInterface().isProtected(); - } - - @Override - public boolean isFinal() { - return getEnclosedMetaObject().isClassOrInterface() != null && - getEnclosedMetaObject().isClassOrInterface().isFinal(); - } - - @Override - public boolean isStatic() { - return getEnclosedMetaObject().isClassOrInterface() != null && - getEnclosedMetaObject().isClassOrInterface().isStatic(); - } - - @Override - public boolean isSynthetic() { - return false; - } - - @Override - public boolean isAnonymousClass() { - return false; - } - - @Override - public MetaClass asArrayOf(final int dimensions) { - JType type = getEnclosedMetaObject(); - for (int i = 0; i < dimensions; i++) { - type = oracle.getArrayType(type); - } - - return new GWTClass(oracle, type, false); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTConstructor.java b/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTConstructor.java deleted file mode 100644 index 41e0c741321..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTConstructor.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta.impl.gwt; - -import java.lang.annotation.Annotation; -import java.util.Arrays; - -import com.google.gwt.core.ext.typeinfo.JConstructor; -import com.google.gwt.core.ext.typeinfo.TypeOracle; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaConstructor; -import org.jboss.errai.codegen.meta.MetaParameter; -import org.jboss.errai.codegen.meta.MetaType; -import org.jboss.errai.codegen.meta.MetaTypeVariable; -import org.jboss.errai.codegen.util.GenUtil; - -/** - * @author Mike Brock - */ -public class GWTConstructor extends MetaConstructor { - private final JConstructor constructor; - private final MetaClass declaringClass; - private final Annotation[] annotations; - private final TypeOracle oracle; - - public GWTConstructor(final TypeOracle oracle, final JConstructor c) { - this.constructor = c; - this.annotations = c.getAnnotations(); - - this.declaringClass = GWTClass.newInstance(oracle, c.getEnclosingType()); - this.oracle = oracle; - } - - @Override - public MetaParameter[] getParameters() { - return Arrays.stream(constructor.getParameters()) - .map(p -> new GWTParameter(oracle, p, this)) - .toArray(s -> new MetaParameter[s]); - } - - @Override - public String getName() { - return ""; - } - - @Override - public MetaClass getReturnType() { - return declaringClass; - } - - @Override - public MetaType getGenericReturnType() { - return declaringClass; - } - - @Override - public MetaClass getDeclaringClass() { - return declaringClass; - } - - @Override - public String getDeclaringClassName() { - return declaringClass.getName(); - } - - @Override - public Annotation[] getAnnotations() { - return annotations; - } - - @Override - public MetaType[] getGenericParameterTypes() { - return null; - } - - @Override - public MetaClass[] getCheckedExceptions() { - return new MetaClass[0]; - } - - @Override - public boolean isVarArgs() { - return constructor.isVarArgs(); - } - - @Override - public boolean isAbstract() { - return false; - } - - @Override - public boolean isPublic() { - return constructor.isPublic(); - } - - @Override - public boolean isPrivate() { - return constructor.isPrivate(); - } - - @Override - public boolean isProtected() { - return constructor.isProtected(); - } - - @Override - public boolean isFinal() { - return false; - } - - @Override - public boolean isStatic() { - return true; - } - - @Override - public boolean isTransient() { - return false; - } - - @Override - public boolean isSynthetic() { - return false; - } - - @Override - public boolean isVolatile() { - return false; - } - - @Override - public boolean isSynchronized() { - return false; - } - - @Override - public MetaTypeVariable[] getTypeParameters() { - return GWTUtil.fromTypeVariable(oracle, constructor.getTypeParameters()); - } - - @Override - public boolean equals(final Object o) { - return o instanceof MetaConstructor && GenUtil.equals(this, (MetaConstructor) o); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTField.java b/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTField.java deleted file mode 100644 index b09df6ff01e..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTField.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta.impl.gwt; - -import java.lang.annotation.Annotation; - -import com.google.gwt.core.ext.typeinfo.JField; -import com.google.gwt.core.ext.typeinfo.TypeOracle; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaField; -import org.jboss.errai.codegen.meta.MetaType; - -/** - * @author Mike Brock - */ -public class GWTField extends MetaField { - private final JField field; - private final Annotation[] annotations; - private final TypeOracle oracle; - - GWTField(final TypeOracle oracle, final JField field) { - this.oracle = oracle; - this.field = field; - this.annotations = field.getAnnotations(); - } - - @Override - public MetaClass getType() { - return GWTUtil.eraseOrReturn(oracle, field.getType()); - } - - @Override - public String getName() { - return field.getName(); - } - - @Override - public Annotation[] getAnnotations() { - return annotations == null ? new Annotation[0] : annotations; - } - - @Override - public MetaType getGenericType() { - return GWTUtil.fromType(oracle, field.getType()); - } - - @Override - public MetaClass getDeclaringClass() { - return GWTClass.newInstance(oracle, field.getEnclosingType()); - } - - @Override - public String getDeclaringClassName() { - return field.getEnclosingType().getName(); - } - - @Override - public boolean isAbstract() { - return false; - } - - @Override - public boolean isPublic() { - return field.isPublic(); - } - - @Override - public boolean isPrivate() { - return field.isPrivate(); - } - - @Override - public boolean isProtected() { - return field.isProtected(); - } - - @Override - public boolean isFinal() { - return field.isFinal(); - } - - @Override - public boolean isStatic() { - return field.isStatic(); - } - - @Override - public boolean isTransient() { - return field.isTransient(); - } - - @Override - public boolean isVolatile() { - return field.isVolatile(); - } - - @Override - public boolean isSynthetic() { - return false; - } - - @Override - public boolean isSynchronized() { - return false; - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTGenericArrayType.java b/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTGenericArrayType.java deleted file mode 100644 index 2ea3fa5fff6..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTGenericArrayType.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta.impl.gwt; - -import com.google.gwt.core.ext.typeinfo.JArrayType; -import com.google.gwt.core.ext.typeinfo.TypeOracle; -import org.jboss.errai.codegen.meta.MetaGenericArrayType; -import org.jboss.errai.codegen.meta.MetaType; - -/** - * @author Mike Brock - */ -public class GWTGenericArrayType implements MetaGenericArrayType { - private final JArrayType arrayType; - private final TypeOracle oracle; - - public GWTGenericArrayType(final TypeOracle oracle, final JArrayType arrayType) { - this.arrayType = arrayType; - this.oracle = oracle; - } - - @Override - public MetaType getGenericComponentType() { - return GWTUtil.fromType(oracle, arrayType.getComponentType()); - } - - @Override - public String getName() { - return arrayType.getParameterizedQualifiedSourceName(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTMethod.java b/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTMethod.java deleted file mode 100644 index 7d4ec345590..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTMethod.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta.impl.gwt; - -import java.lang.annotation.Annotation; -import java.util.Arrays; - -import com.google.gwt.core.ext.typeinfo.JMethod; -import com.google.gwt.core.ext.typeinfo.JType; -import com.google.gwt.core.ext.typeinfo.TypeOracle; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaMethod; -import org.jboss.errai.codegen.meta.MetaParameter; -import org.jboss.errai.codegen.meta.MetaType; -import org.jboss.errai.codegen.meta.MetaTypeVariable; -import org.jboss.errai.codegen.util.GenUtil; - -/** - * @author Mike Brock - */ -public class GWTMethod extends MetaMethod { - - private final JMethod method; - private volatile Annotation[] annotations; - private final TypeOracle oracle; - - GWTMethod(final TypeOracle oracle, final JMethod method) { - this.method = method; - this.annotations = method.getAnnotations(); - this.oracle = oracle; - } - - @Override - public String getName() { - return method.getName(); - } - - @Override - public MetaClass getReturnType() { - return GWTUtil.eraseOrReturn(oracle, method.getReturnType()); - } - - @Override - public MetaParameter[] getParameters() { - return Arrays.stream(method.getParameters()) - .map(p -> new GWTParameter(oracle, p, this)) - .toArray(s -> new GWTParameter[s]); - } - - @Override - public synchronized Annotation[] getAnnotations() { - return annotations; - } - - @Override - public MetaClass getDeclaringClass() { - return GWTClass.newInstance(oracle, method.getEnclosingType()); - } - - @Override - public String getDeclaringClassName() { - return method.getEnclosingType().getName(); - } - - @Override - public MetaType getGenericReturnType() { - try { - final JType returnType = method.getReturnType(); - return GWTUtil.fromType(oracle, returnType); - } - catch (final Exception e) { - throw new RuntimeException( - "Failed to produce a generic MetaType for return type of method " + - method.getReadableDeclaration() + " in class " + - method.getEnclosingType().getQualifiedSourceName() + - " (underlying GWT return type is " + - method.getReturnType().getClass() + ")", e); - } - } - - @Override - public MetaType[] getGenericParameterTypes() { - return Arrays.stream(method.getParameters()) - .map(p -> GWTUtil.fromType(oracle, p.getType())) - .toArray(s -> new MetaType[s]); - } - - @Override - public MetaClass[] getCheckedExceptions() { - return GWTClass.fromClassArray(oracle, method.getThrows()); - } - - @Override - public boolean isAbstract() { - return method.isAbstract(); - } - - @Override - public boolean isPublic() { - return method.isPublic(); - } - - @Override - public boolean isPrivate() { - return method.isPrivate(); - } - - @Override - public boolean isProtected() { - return method.isProtected(); - } - - @Override - public boolean isFinal() { - return method.isFinal(); - } - - @Override - public boolean isStatic() { - return method.isStatic(); - } - - @Override - public boolean isTransient() { - return false; - } - - @Override - public boolean isVolatile() { - return false; - } - - @Override - public boolean isSynthetic() { - return false; - } - - @Override - public boolean isSynchronized() { - return false; - } - - @Override - public boolean isVarArgs() { - return method.isVarArgs(); - } - - @Override - public MetaTypeVariable[] getTypeParameters() { - return GWTUtil.fromTypeVariable(oracle, method.getTypeParameters()); - } - - @Override - public boolean equals(final Object o) { - return o instanceof MetaMethod && GenUtil.equals(this, (MetaMethod) o); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTParameter.java b/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTParameter.java deleted file mode 100644 index ab3fec150c6..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTParameter.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta.impl.gwt; - -import java.lang.annotation.Annotation; - -import com.google.gwt.core.ext.typeinfo.JParameter; -import com.google.gwt.core.ext.typeinfo.TypeOracle; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassMember; -import org.jboss.errai.codegen.meta.MetaConstructor; -import org.jboss.errai.codegen.meta.MetaMethod; -import org.jboss.errai.codegen.meta.MetaParameter; - -/** - * @author Mike Brock - */ -public class GWTParameter extends MetaParameter { - private final JParameter parameter; - private final Annotation[] annotations; - private final MetaClassMember declaredBy; - private final TypeOracle oracle; - - GWTParameter(final TypeOracle oracle, final JParameter parameter, final MetaMethod declaredBy) { - this(oracle, parameter, (MetaClassMember) declaredBy); - } - - GWTParameter(final TypeOracle oracle, final JParameter parameter, final MetaConstructor declaredBy) { - this(oracle, parameter, (MetaClassMember) declaredBy); - } - - private GWTParameter(final TypeOracle oracle, final JParameter parameter, final MetaClassMember declaredBy) { - this.parameter = parameter; - this.annotations = parameter.getAnnotations(); - this.declaredBy = declaredBy; - this.oracle = oracle; - } - - @Override - public String getName() { - return parameter.getName(); - } - - @Override - public MetaClass getType() { - return GWTUtil.eraseOrReturn(oracle, parameter.getType()); - } - - @Override - public Annotation[] getAnnotations() { - return annotations; - } - - @Override - public MetaClassMember getDeclaringMember() { - return declaredBy; - } - - @Override - public String toString() { - return getType().getFullyQualifiedName(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTParameterizedType.java b/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTParameterizedType.java deleted file mode 100644 index 42fd8e31142..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTParameterizedType.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta.impl.gwt; - -import java.util.ArrayList; -import java.util.List; - -import com.google.gwt.core.ext.typeinfo.JArrayType; -import com.google.gwt.core.ext.typeinfo.JClassType; -import com.google.gwt.core.ext.typeinfo.JParameterizedType; -import com.google.gwt.core.ext.typeinfo.JType; -import com.google.gwt.core.ext.typeinfo.TypeOracle; -import org.jboss.errai.codegen.meta.MetaType; -import org.jboss.errai.codegen.meta.impl.AbstractMetaParameterizedType; - -/** - * @author Mike Brock - */ -public class GWTParameterizedType extends AbstractMetaParameterizedType { - private final JParameterizedType parameterizedType; - private final TypeOracle oracle; - - public GWTParameterizedType(final TypeOracle oracle, final JParameterizedType parameterizedType) { - this.parameterizedType = parameterizedType; - this.oracle = oracle; - } - - @Override - public MetaType[] getTypeParameters() { - final List types = new ArrayList<>(); - for (final JClassType parm : parameterizedType.getTypeArgs()) { - if (parm.isWildcard() != null) { - types.add(new GWTWildcardType(oracle, parm.isWildcard())); - } - else if (parm.isTypeParameter() != null) { - types.add(new GWTTypeVariable(oracle, parm.isTypeParameter())); - } - else if (parm.isArray() != null - && isInnerMostComponentTypeParameter(parm.isArray())) { - // is generic array. Erase to Object[] - types.add(GWTClass.newInstance(oracle, parm.isArray().getErasedType())); - } - else if (parm.isClassOrInterface() != null - || parm.isEnum() != null - || parm.isPrimitive() != null - || parm.isRawType() != null - || parm.isArray() != null - || parm.isAnnotation() != null) { - types.add(GWTClass.newInstance(oracle, parm)); - } - else { - throw new IllegalArgumentException("Unsupported kind of type parameter " + parm + " in type " + parameterizedType.getName()); - } - } - return types.toArray(new MetaType[types.size()]); - } - - private boolean isInnerMostComponentTypeParameter(final JArrayType parm) { - final JType componentType = parm.isArray().getComponentType(); - if (componentType.isArray() != null) { - return isInnerMostComponentTypeParameter(componentType.isArray()); - } - else { - return componentType.isTypeParameter() != null; - } - } - - @Override - public MetaType getOwnerType() { - return GWTClass.newInstance(oracle, parameterizedType.getEnclosingType()); - } - - @Override - public MetaType getRawType() { - return GWTClass.newInstance(oracle, parameterizedType.getRawType()); - } - - @Override - public String getName() { - return parameterizedType.getParameterizedQualifiedSourceName(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTSpecialMethod.java b/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTSpecialMethod.java deleted file mode 100644 index d1330a0eb2c..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTSpecialMethod.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta.impl.gwt; - -import java.lang.annotation.Annotation; - -import org.jboss.errai.codegen.DefModifiers; -import org.jboss.errai.codegen.Modifier; -import org.jboss.errai.codegen.builder.impl.Scope; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.meta.MetaMethod; -import org.jboss.errai.codegen.meta.MetaParameter; -import org.jboss.errai.codegen.meta.MetaType; -import org.jboss.errai.codegen.meta.MetaTypeVariable; - -/** - * @author Mike Brock - */ -public class GWTSpecialMethod extends MetaMethod { - private final DefModifiers modifiers; - private final Scope scope; - private final GWTClass declaringClass; - private final MetaClass returnType; - private final String methodName; - private final MetaParameter[] parameters; - - GWTSpecialMethod(final GWTClass declaringClass, - final DefModifiers modifiers, - final Scope scope, - final Class returnType, - final String methodName, - final MetaParameter... parameters) { - this(declaringClass, modifiers, scope, MetaClassFactory.get(returnType), methodName, parameters); - } - - GWTSpecialMethod(final GWTClass declaringClass, - final DefModifiers modifiers, - final Scope scope, - final MetaClass returnType, - final String methodName, - final MetaParameter... parameters) { - this.declaringClass = declaringClass; - this.modifiers = modifiers; - this.scope = scope; - this.returnType = returnType; - this.methodName = methodName; - this.parameters = parameters; - } - - @Override - public String getName() { - return methodName; - } - - @Override - public MetaClass getReturnType() { - return returnType; - } - - @Override - public MetaParameter[] getParameters() { - return parameters; - } - - @Override - public Annotation[] getAnnotations() { - return new Annotation[0]; - } - - @Override - public MetaClass getDeclaringClass() { - return declaringClass; - } - - @Override - public String getDeclaringClassName() { - return declaringClass.getName(); - } - - @Override - public MetaType getGenericReturnType() { - return null; - } - - @Override - public MetaType[] getGenericParameterTypes() { - return new MetaType[0]; - } - - @Override - public MetaClass[] getCheckedExceptions() { - return new MetaClass[0]; - } - - @Override - public boolean isAbstract() { - return modifiers.hasModifier(Modifier.Abstract); - } - - @Override - public boolean isPublic() { - return scope == Scope.Public; - } - - @Override - public boolean isPrivate() { - return scope == Scope.Private; - } - - @Override - public boolean isProtected() { - return scope == Scope.Protected; - } - - @Override - public boolean isFinal() { - return modifiers.hasModifier(Modifier.Final); - } - - @Override - public boolean isStatic() { - return modifiers.hasModifier(Modifier.Static); - } - - @Override - public boolean isTransient() { - return false; - } - - @Override - public boolean isVolatile() { - return false; - } - - @Override - public boolean isSynthetic() { - return false; - } - - @Override - public boolean isSynchronized() { - return false; - } - - @Override - public boolean isVarArgs() { - return false; - } - - @Override - public MetaTypeVariable[] getTypeParameters() { - return new MetaTypeVariable[0]; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTTypeVariable.java b/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTTypeVariable.java deleted file mode 100644 index a083de881ea..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTTypeVariable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta.impl.gwt; - -import com.google.gwt.core.ext.typeinfo.JTypeParameter; -import com.google.gwt.core.ext.typeinfo.TypeOracle; -import org.jboss.errai.codegen.meta.MetaType; -import org.jboss.errai.codegen.meta.MetaTypeVariable; - -/** - * @author Mike Brock - */ -public class GWTTypeVariable implements MetaTypeVariable { - private final JTypeParameter typeParameter; - private final TypeOracle oracle; - - public GWTTypeVariable(final TypeOracle oracle, final JTypeParameter typeParameter) { - this.typeParameter = typeParameter; - this.oracle = oracle; - } - - @Override - public MetaType[] getBounds() { - return GWTUtil.fromTypeArray(oracle, typeParameter.getBounds()); - } - - @Override - public String getName() { - return typeParameter.getName(); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTUtil.java b/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTUtil.java deleted file mode 100644 index 225c8209aff..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTUtil.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta.impl.gwt; - -import java.util.Arrays; - -import com.google.gwt.core.ext.typeinfo.JArrayType; -import com.google.gwt.core.ext.typeinfo.JType; -import com.google.gwt.core.ext.typeinfo.JTypeParameter; -import com.google.gwt.core.ext.typeinfo.JWildcardType; -import com.google.gwt.core.ext.typeinfo.TypeOracle; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.meta.MetaType; -import org.jboss.errai.codegen.meta.MetaTypeVariable; - -/** - * @author Mike Brock - */ -public class GWTUtil { - - public static MetaTypeVariable[] fromTypeVariable(final TypeOracle oracle, - final JTypeParameter[] typeParameters) { - - return Arrays.stream(typeParameters).map(p -> new GWTTypeVariable(oracle, p)).toArray(s -> new MetaTypeVariable[s]); - } - - public static MetaType[] fromTypeArray(final TypeOracle oracle, final JType[] types) { - return Arrays.stream(types).map(t -> fromType(oracle, t)).toArray(s -> new MetaType[s]); - } - - private static JType getRootComponentType(JArrayType type) { - JType root = null; - while (type.getComponentType() != null) { - if (type.getComponentType().isArray() != null) { - type = type.getComponentType().isArray(); - } - else { - root = type.getComponentType(); - break; - } - - } - return root; - } - - public static MetaClass eraseOrReturn(final TypeOracle oracle, final JType t) { - - if (t.isArray() != null) { - final JType root = getRootComponentType(t.isArray()); - if (root.isTypeParameter() != null) { - return MetaClassFactory.get(Object.class); - } - } - - if (t.isTypeParameter() != null) { - final JTypeParameter tp = t.isTypeParameter(); - return MetaClassFactory.get(tp.getErasedType().getQualifiedBinaryName()); - } - else if (t.isWildcard() != null) { - final JWildcardType wildcard = t.isWildcard(); - return MetaClassFactory.get(wildcard.getBaseType().getQualifiedBinaryName()); - } - else { - return GWTClass.newInstance(oracle, t); - } - } - - public static MetaType fromType(final TypeOracle oracle, final JType t) { - if (t.isTypeParameter() != null) { - return new GWTTypeVariable(oracle, t.isTypeParameter()); - } - else if (t.isArray() != null - && (t.isArray().getComponentType().isTypeParameter() != null - || t.isArray().getComponentType().isWildcard() != null)) { - return new GWTGenericArrayType(oracle, t.isArray()); - } - else if (t.isParameterized() != null) { - return new GWTParameterizedType(oracle, t.isParameterized()); - } - else if (t.isWildcard() != null) { - return new GWTWildcardType(oracle, t.isWildcard()); - } - else if (t.isClassOrInterface() != null - || t.isEnum() != null - || t.isPrimitive() != null - || t.isRawType() != null - || t.isArray() != null) { - return GWTClass.newInstance(oracle, t); - } - else { - throw new RuntimeException("Don't know how to make a MetaType from given JType " + t + - " (which is a " + (t.getClass()) + ")"); - } - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTWildcardType.java b/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTWildcardType.java deleted file mode 100644 index dc03bf1642d..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/meta/impl/gwt/GWTWildcardType.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta.impl.gwt; - -import com.google.gwt.core.ext.typeinfo.JWildcardType; -import com.google.gwt.core.ext.typeinfo.TypeOracle; -import org.jboss.errai.codegen.meta.MetaType; -import org.jboss.errai.codegen.meta.impl.AbstractMetaWildcardType; - -/** - * @author Mike Brock - */ -public class GWTWildcardType extends AbstractMetaWildcardType { - private final JWildcardType wildcardType; - private final TypeOracle oracle; - - public GWTWildcardType(final TypeOracle oracle, final JWildcardType wildcardType) { - this.wildcardType = wildcardType; - this.oracle = oracle; - } - - @Override - public MetaType[] getLowerBounds() { - return GWTUtil.fromTypeArray(oracle, wildcardType.getLowerBounds()); - } - - @Override - public MetaType[] getUpperBounds() { - return GWTUtil.fromTypeArray(oracle, wildcardType.getUpperBounds()); - } - - @Override - public String getName() { - return wildcardType.getParameterizedQualifiedSourceName(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/util/GWTPrivateMemberAccessor.java b/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/util/GWTPrivateMemberAccessor.java deleted file mode 100644 index 9339b64720e..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/util/GWTPrivateMemberAccessor.java +++ /dev/null @@ -1,197 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.util; - -import java.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.List; - -import com.google.gwt.core.client.UnsafeNativeLong; -import org.jboss.errai.codegen.DefParameters; -import org.jboss.errai.codegen.Modifier; -import org.jboss.errai.codegen.Parameter; -import org.jboss.errai.codegen.StringStatement; -import org.jboss.errai.codegen.builder.ClassStructureBuilder; -import org.jboss.errai.codegen.builder.MethodBlockBuilder; -import org.jboss.errai.codegen.builder.MethodCommentBuilder; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaConstructor; -import org.jboss.errai.codegen.meta.MetaField; -import org.jboss.errai.codegen.meta.MetaMethod; -import org.jboss.errai.codegen.meta.MetaParameter; - -/** - * @author Mike Brock - */ -public class GWTPrivateMemberAccessor implements PrivateMemberAccessor { - - /** - * Annotation instance that can be passed to the code generator when generating long accessors. - */ - private static final UnsafeNativeLong UNSAFE_NATIVE_LONG_ANNOTATION = new UnsafeNativeLong() { - @Override - public Class annotationType() { - return UnsafeNativeLong.class; - } - }; - - /** - * A reusable empty annotation array. - */ - private static final Annotation[] NO_ANNOTATIONS = new Annotation[0]; - - @Override - public void createWritableField(final MetaClass type, - final ClassStructureBuilder classBuilder, - final MetaField field, - final Modifier[] modifiers) { - - final MethodCommentBuilder> methodBuilder = - classBuilder.packageMethod(void.class, PrivateAccessUtil.getPrivateFieldAccessorName(field)); - - if (type.getCanonicalName().equals("long")) { - methodBuilder.annotatedWith(UNSAFE_NATIVE_LONG_ANNOTATION); - } - - if (!field.isStatic()) { - methodBuilder - .parameters(DefParameters.fromParameters(Parameter.of(field.getDeclaringClass().getErased(), "instance"), - Parameter.of(type, "value"))); - } else { - methodBuilder - .parameters(DefParameters.fromParameters(Parameter.of(type, "value"))); - } - - methodBuilder.modifiers(appendJsni(modifiers)) - .body() - ._(StringStatement.of(JSNIUtil.fieldAccess(field) + " = value")) - .finish(); - } - - @Override - public void createReadableField(final MetaClass type, - final ClassStructureBuilder classBuilder, - final MetaField field, - final Modifier[] modifiers) { - - final MethodBlockBuilder> instance = - classBuilder.packageMethod(type, PrivateAccessUtil.getPrivateFieldAccessorName(field)); - - if (!field.isStatic()) { - instance.parameters(DefParameters.fromParameters(Parameter.of(field.getDeclaringClass().getErased(), "instance"))); - } - - if (type.getCanonicalName().equals("long")) { - instance.annotatedWith(UNSAFE_NATIVE_LONG_ANNOTATION); - } - - instance.modifiers(appendJsni(modifiers)) - .body() - ._(StringStatement.of("return " + JSNIUtil.fieldAccess(field))) - .finish(); - } - - @Override - public void makeMethodAccessible(final ClassStructureBuilder classBuilder, - final MetaMethod method, - final Modifier[] modifiers) { - - final MetaMethod erasedMethod = method.getDeclaringClass().getErased().getDeclaredMethod(method.getName(), - getErasedParamterTypes(method)); - - final List wrapperDefParms = new ArrayList(); - - if (!erasedMethod.isStatic()) { - wrapperDefParms.add(Parameter.of(erasedMethod.getDeclaringClass().getErased(), "instance")); - } - - final List methodDefParms = DefParameters.from(erasedMethod).getParameters(); - wrapperDefParms.addAll(methodDefParms); - - Annotation[] annotations = NO_ANNOTATIONS; - for (MetaParameter p : erasedMethod.getParameters()) { - if (p.getType().getCanonicalName().equals("long")) { - annotations = new Annotation[] { UNSAFE_NATIVE_LONG_ANNOTATION }; - } - } - if (erasedMethod.getReturnType().getCanonicalName().equals("long")) { - annotations = new Annotation[] { UNSAFE_NATIVE_LONG_ANNOTATION }; - } - - classBuilder.publicMethod(erasedMethod.getReturnType(), PrivateAccessUtil.getPrivateMethodName(method)) - .annotatedWith(annotations) - .parameters(DefParameters.fromParameters(wrapperDefParms)) - .modifiers(appendJsni(modifiers)) - .body() - ._(StringStatement.of(JSNIUtil.methodAccess(erasedMethod))) - .finish(); - } - - private MetaClass[] getErasedParamterTypes(final MetaMethod method) { - final MetaClass[] paramTypes = new MetaClass[method.getParameters().length]; - for (int i = 0; i < paramTypes.length; i++) { - paramTypes[i] = method.getParameters()[i].getType().getErased(); - } - - return paramTypes; - } - - @Override - public void makeConstructorAccessible(final ClassStructureBuilder classBuilder, - final MetaConstructor constructor) { - - final DefParameters methodDefParms = DefParameters.from(constructor); - - Annotation[] annotations = NO_ANNOTATIONS; - for (MetaParameter p : constructor.getParameters()) { - if (p.getType().getCanonicalName().equals("long")) { - annotations = new Annotation[] { UNSAFE_NATIVE_LONG_ANNOTATION }; - } - } - - classBuilder.publicMethod(constructor.getReturnType(), PrivateAccessUtil.getPrivateMethodName(constructor)) - .annotatedWith(annotations) - .parameters(methodDefParms) - .modifiers(Modifier.Static, Modifier.JSNI) - .body() - ._(StringStatement.of(JSNIUtil.methodAccess(constructor))) - .finish(); - } - - /** - * Returns a new array consisting of a copy of the given array, plus - * Modifiers.JSNI as the last element. - * - * @param modifiers - * The array to copy. May be empty, but must not be null. - * - * @return An array of length {@code n + 1}, where {@code n} is the length of - * the given array. Positions 0..n-1 correspond with the respective - * entries in the given array, and position n contains Modifiers.JSNI. - */ - public static Modifier[] appendJsni(Modifier[] modifiers) { - final Modifier[] origModifiers = modifiers; - modifiers = new Modifier[origModifiers.length + 1]; - System.arraycopy(origModifiers, 0, modifiers, 0, origModifiers.length); - modifiers[modifiers.length - 1] = Modifier.JSNI; - return modifiers; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/util/JSNIUtil.java b/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/util/JSNIUtil.java deleted file mode 100644 index 75abc551bc5..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/main/java/org/jboss/errai/codegen/util/JSNIUtil.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.util; - -import org.jboss.errai.codegen.meta.MetaConstructor; -import org.jboss.errai.codegen.meta.MetaField; -import org.jboss.errai.codegen.meta.MetaMethod; -import org.jboss.errai.codegen.meta.MetaParameter; - -/** - * @author Mike Brock - */ -public class JSNIUtil { - public static String fieldAccess(final MetaField field) { - if (field.isStatic()) { - return "@" + field.getDeclaringClass().getFullyQualifiedName().replace('$', '.') + "::" - + field.getName(); - } - else { - return "instance.@" + field.getDeclaringClass().getFullyQualifiedName().replace('$', '.') + "::" - + field.getName(); - } - } - - public static String methodAccess(final MetaMethod method) { - final StringBuilder buf = new StringBuilder(50); - - if (!method.getReturnType().isVoid()) { - buf.append("return "); - } - - if (!method.isStatic()) { - buf.append("instance."); - } - - buf.append('@').append(method.getDeclaringClass().getFullyQualifiedName().replace('$', '.')) - .append("::").append(method instanceof MetaConstructor ? "new" : method.getName()).append('('); - - for (final MetaParameter parm : method.getParameters()) { - buf.append(parm.getType().getInternalName()); - } - buf.append(")("); - - final int length = method.getParameters().length; - - for (int i = 0; i < length; i++) { - buf.append("a").append(i); - if (i + 1 < length) buf.append(","); - } - buf.append(")"); - - return buf.toString(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/test/java/org/jboss/errai/codegen/gwt/test/GWTMetaClassTest.java b/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/test/java/org/jboss/errai/codegen/gwt/test/GWTMetaClassTest.java deleted file mode 100644 index e1e7b73645f..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/test/java/org/jboss/errai/codegen/gwt/test/GWTMetaClassTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.gwt.test; - -import java.io.File; - -import com.google.gwt.core.ext.typeinfo.TypeOracle; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.impl.gwt.GWTClass; -import org.jboss.errai.codegen.test.meta.AbstractMetaClassTest; -import org.jboss.errai.codegen.test.model.PrimitiveFieldContainer; - -/** - * The GWT implementation of the overall MetaClass test. Inherits all the tests - * from AbstractMetaClassTest and runs them against GWTClass. Don't remove this - * test! It actually does something! - * - * @author Mike Brock - * @author Jonathan Fuerth - */ -public class GWTMetaClassTest extends AbstractMetaClassTest { - - private static final TypeOracle mockacle; - static { - final MockacleFactory f = new MockacleFactory(new File("../errai-codegen/src/test/java")); - f.addTestClass("org.jboss.errai.codegen.test.model.tree.Child"); - f.addTestClass("org.jboss.errai.codegen.test.model.tree.Grandparent"); - f.addTestClass("org.jboss.errai.codegen.test.model.tree.GrandparentInterface"); - f.addTestClass("org.jboss.errai.codegen.test.model.tree.GrandparentSuperInterface"); - f.addTestClass("org.jboss.errai.codegen.test.model.tree.IsolatedInterface"); - f.addTestClass("org.jboss.errai.codegen.test.model.tree.Parent"); - f.addTestClass("org.jboss.errai.codegen.test.model.tree.ParentInterface"); - f.addTestClass("org.jboss.errai.codegen.test.model.tree.ParentSuperInterface1"); - f.addTestClass("org.jboss.errai.codegen.test.model.tree.ParentSuperInterface2"); - f.addTestClass("org.jboss.errai.codegen.test.model.TestInterface"); - f.addTestClass("org.jboss.errai.codegen.test.model.ObjectWithNested"); - f.addTestClass("org.jboss.errai.codegen.test.model.ClassWithGenericCollections"); - f.addTestClass("org.jboss.errai.codegen.test.model.ParameterizedClass"); - f.addTestClass("org.jboss.errai.codegen.test.model.ClassWithGenericMethods"); - f.addTestClass("org.jboss.errai.codegen.test.model.HasManyConstructors"); - f.addTestClass("org.jboss.errai.codegen.test.model.GenericSuperClass"); - f.addTestClass("org.jboss.errai.codegen.test.model.GenericArraySubclass"); - f.addTestClass("org.jboss.errai.codegen.test.model.ClassWithArrayGenerics"); - f.addTestClass(PrimitiveFieldContainer.class.getName()); - - mockacle = f.generateMockacle(); - } - - @Override - protected MetaClass getMetaClassImpl(Class javaClass) { - - int dims = 0; - while (javaClass.isArray()) { - javaClass = javaClass.getComponentType(); - dims++; - } - - MetaClass metaClass; - if (javaClass.isPrimitive()) { - // This is a hack for getting a JType for a primitive - // (I couldn't find any Source implementation that does it directly) - final MetaClass container = GWTClass.newInstance(mockacle, PrimitiveFieldContainer.class.getName()); - metaClass = container.getDeclaredField(javaClass.getName() + "Field").getType(); - } - else { - metaClass = GWTClass.newInstance(mockacle, javaClass.getName()); - } - - if (metaClass == null) { - throw new RuntimeException("Oops, the mock TypeOracle doesn't know about " + javaClass); - } - - if (dims > 0) { - metaClass = metaClass.asArrayOf(dims); - } - - return metaClass; - } - - @Override - protected Class getTypeOfMetaClassBeingTested() { - return GWTClass.class; - } - - // NOTE: all of the test methods are inherited from AbstractMetaClassTest -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/test/java/org/jboss/errai/codegen/gwt/test/GWTParameterizedTypeTest.java b/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/test/java/org/jboss/errai/codegen/gwt/test/GWTParameterizedTypeTest.java deleted file mode 100644 index 70430b7b9d4..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/test/java/org/jboss/errai/codegen/gwt/test/GWTParameterizedTypeTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.gwt.test; - -import java.io.File; - -import com.google.gwt.core.ext.typeinfo.JClassType; -import com.google.gwt.core.ext.typeinfo.JType; -import com.google.gwt.core.ext.typeinfo.TypeOracle; -import org.jboss.errai.codegen.meta.MetaType; -import org.jboss.errai.codegen.meta.impl.gwt.GWTParameterizedType; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class GWTParameterizedTypeTest { - - private static final TypeOracle mockacle; - static { - MockacleFactory f = new MockacleFactory(new File( - "../errai-codegen/src/test/java")); - f.addTestClass("org.jboss.errai.codegen.test.model.GenericArrayCollectionTestModel"); - - mockacle = f.generateMockacle(); - } - - @Test - public void getTypeParameters_GenericArray() { - JClassType type = mockacle - .findType("org.jboss.errai.codegen.test.model.GenericArrayCollectionTestModel"); - JType returnType = type.getMethods()[0].getReturnType(); - GWTParameterizedType parameterizedType = new GWTParameterizedType(mockacle, - returnType.isParameterized()); - MetaType[] typeParameters = parameterizedType.getTypeParameters(); - assertEquals(typeParameters.length, 1); - assertEquals(typeParameters[0].getName(), "Object[]"); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/test/java/org/jboss/errai/codegen/gwt/test/MockacleFactory.java b/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/test/java/org/jboss/errai/codegen/gwt/test/MockacleFactory.java deleted file mode 100644 index ceb0f9319b5..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/test/java/org/jboss/errai/codegen/gwt/test/MockacleFactory.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.gwt.test; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import com.google.gwt.core.ext.GeneratorContext; -import com.google.gwt.core.ext.typeinfo.TypeOracle; -import com.google.gwt.dev.javac.testing.GeneratorContextBuilder; -import com.google.gwt.dev.javac.testing.JavaSource; -import com.google.gwt.dev.javac.testing.Source; -import org.jboss.errai.common.metadata.RebindUtils; - -/** - * A factory that helps create a mock TypeOracle that knows about a certain - * collection of classes. - * - * @author Mike Brock - * @author Jonathan Fuerth - */ -public final class MockacleFactory { - - private static final Source MVEL_NULL_TYPE = new JavaSource("org.mvel2.util.NullType") { - @Override - public String getSource() { - return "package org.mvel2.util;" + - "public class NullType {}"; - } - }; - - private final File pathToTestFiles; - private final List sourceFilesToAdd = new ArrayList(); - - /** - * Creates a new type oracle factory that can load classes whose source is - * rooted at the given directory. - * - * @param sourceDir - * The root directory for the tree of .java files that will be loaded - * into the mock TypeOracle. Must exist and must be a directory. - */ - public MockacleFactory(File sourceDir) { - if (!sourceDir.exists()) { - throw new IllegalArgumentException("Source location " + sourceDir.getAbsolutePath() + " does not exist"); - } - if (!sourceDir.isDirectory()) { - throw new IllegalArgumentException("Source location " + sourceDir.getAbsolutePath() + " is not a directory"); - } - pathToTestFiles = sourceDir; - - sourceFilesToAdd.add(MVEL_NULL_TYPE); - } - - public void addTestClass(final String fqcn) { - - sourceFilesToAdd.add(new JavaSource(fqcn) { -// @Override -// public String getPath() { -// return getRelativePathToClassFromName(fqcn); -// } - - @Override - public String getSource() { - return RebindUtils.readFileToString(new File(pathToTestFiles, getPath())); - } - }); - } - - public TypeOracle generateMockacle() { - final GeneratorContextBuilder contextBuilder = GeneratorContextBuilder.newCoreBasedBuilder(); - - for (final Source source : sourceFilesToAdd) { - contextBuilder.add(source); - } - - final GeneratorContext context = contextBuilder.buildGeneratorContext(); - - return context.getTypeOracle(); - } - - private static String getPackageFromFQCN(final String fqcn) { - final int index = fqcn.lastIndexOf('.'); - if (index == -1) { - return ""; - } - else { - return fqcn.substring(0, index); - } - } - - private static String getNameFromFQCN(final String fqcn) { - final int index = fqcn.lastIndexOf('.'); - if (index == -1) { - return fqcn; - } - else { - return fqcn.substring(index + 1); - } - } - - private static String getRelativePathToClassFromName(final String fqcn) { - return fqcn.replaceAll("\\.", "/") + ".java"; - } - - private String getFullyQualifiedPathToClassFromName(final String fqcn) { - return new File(pathToTestFiles, getPackageFromFQCN(fqcn)).getAbsolutePath(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/test/resources/log4j.properties b/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/test/resources/log4j.properties deleted file mode 100644 index 7d35540d698..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen-gwt/src/test/resources/log4j.properties +++ /dev/null @@ -1,28 +0,0 @@ -# -# 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. -# - -log4j.rootLogger=INFO, A1 -log4j.appender.A1=org.apache.log4j.ConsoleAppender -log4j.appender.A1.layout=org.apache.log4j.PatternLayout -log4j.appender.A1.layout.ConversionPattern=%d %-5p %c - %m%n - -log4j.logger=INFO - -#log4j.logger.org.jboss.errai.reflections=DEBUG -#log4j.logger.org.jboss.errai.ioc.rebind.ioc.bootstrapper=DEBUG diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/pom.xml b/packages/serverless-workflow-diagram-editor/errai-codegen/pom.xml deleted file mode 100644 index 0411ed039a4..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/pom.xml +++ /dev/null @@ -1,226 +0,0 @@ - - - - org.kie.kogito.stunner.serverless.editor - stunner-editors-parent - ${revision} - - 4.0.0 - Errai::Codegen - errai-codegen - - - - org.eclipse.jdt - ecj - - - - org.kie.kogito.stunner.serverless.editor - errai-common - - - - javax.enterprise - cdi-api - provided - - - - org.jboss.spec.javax.annotation - jboss-annotations-api_1.3_spec - provided - - - - org.mvel - mvel2 - - - - junit - junit - - - - - org.gwtproject - gwt-dev - - - - com.google.code.findbugs - jsr305 - - - com.google.code.gson - gson - - - org.ow2.asm - asm - - - org.ow2.asm - asm-util - - - org.ow2.asm - asm-commons - - - colt - colt - - - ant - ant - - - commons-collections - commons-collections - - - commons-io - commons-io - - - com.ibm.icu - icu4j - - - tapestry - tapestry - - - net.sourceforge.htmlunit - htmlunit - - - org.eclipse.jetty - jetty-webapp - - - org.eclipse.jetty - jetty-servlets - - - org.eclipse.jetty - jetty-annotations - - - org.eclipse.jetty - apache-jsp - - - - - - - - - maven-shade-plugin - - - package - - shade - - - true - true - - - org.eclipse.jdt:ecj - org.gwtproject:gwt-dev - - - - - org.gwtproject:gwt-dev - - com/google/gwt/** - org/eclipse/jdt/** - - - - - - org.eclipse.jdt - org.jboss.errai.codegen.shade.org.eclipse.jdt - - org.eclipse.jdt.core.prefs - - - - org.osgi - org.jboss.errai.codegen.shade.org.osgi - - - - - - - - - - - - maven-surefire-plugin - - - - - ${basedir}/target/test-classes - ${basedir}/target/classes - ${basedir}/src/main/java - ${basedir}/src/test/java - - - true - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - test-jar - - - - - - - - - - integration-test - - - - org.codehaus.mojo - selenium-maven-plugin - - true - - - - maven-failsafe-plugin - - true - - - - - - - diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/AbstractStatement.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/AbstractStatement.java deleted file mode 100644 index 13211c35a4f..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/AbstractStatement.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Christian Sadilek - */ -public abstract class AbstractStatement implements Statement { - @Override - public MetaClass getType() { - return null; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/AnnotationEncoder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/AnnotationEncoder.java deleted file mode 100644 index 124e801ef82..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/AnnotationEncoder.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -import java.lang.annotation.Annotation; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import org.jboss.errai.codegen.builder.AnonymousClassStructureBuilder; -import org.jboss.errai.codegen.builder.impl.ObjectBuilder; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.util.Stmt; - -import static org.jboss.errai.codegen.util.PrettyPrinter.prettyPrintJava; - -public class AnnotationEncoder { - public static Statement encode(final Annotation annotation) { - final Class annotationClass = annotation.annotationType(); - - return new Statement() { - String generatedCache; - - @Override - public String generate(final Context context) { - if (generatedCache != null) return generatedCache; - - final AnonymousClassStructureBuilder builder - = ObjectBuilder.newInstanceOf(annotationClass, context) - .extend(); - - final List sortedMethods = Arrays.asList(annotation.getClass().getDeclaredMethods()); - Collections.sort(sortedMethods, new Comparator() { - @Override - public int compare(final Method m1, final Method m2) { - return m1.getName().compareTo(m2.getName()); - } - - }); - - for (final Method method : sortedMethods) { - if (((method.getModifiers() & (Modifier.PRIVATE | Modifier.PROTECTED)) == 0) - && (!"equals".equals(method.getName()) && !"hashCode".equals(method.getName()))) { - try { - method.setAccessible(true); - builder.publicOverridesMethod(method.getName()) - .append(Stmt.load(method.invoke(annotation)).returnValue()).finish(); - } - catch (IllegalAccessException e) { - throw new RuntimeException("error generation annotation wrapper", e); - } - catch (InvocationTargetException e) { - throw new RuntimeException("error generation annotation wrapper", e); - } - } - } - - return generatedCache = prettyPrintJava(builder.finish().toJavaString()); - } - - @Override - public MetaClass getType() { - return MetaClassFactory.get(annotationClass); - } - }; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/ArithmeticExpression.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/ArithmeticExpression.java deleted file mode 100644 index 577c1e40f30..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/ArithmeticExpression.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -/** - * Represents an arithmetic expression. - * - * @author Christian Sadilek - */ -public interface ArithmeticExpression extends Expression, Statement { - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/ArithmeticOperator.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/ArithmeticOperator.java deleted file mode 100644 index d25658ffa71..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/ArithmeticOperator.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Christian Sadilek - */ -public enum ArithmeticOperator implements Operator { - - Addition ("+", 0, Number.class), - Subtraction ("-", 0, Number.class), - Multiplication ("*", 1, Number.class), - Division ("/", 1, Number.class), - Remainder ("%", 1, Number.class); - - private final Operator operator; - - ArithmeticOperator(final String canonicalString, - final int operatorPrecedence, - final Class... constraints) { - - operator = new OperatorImpl(canonicalString, operatorPrecedence, constraints); - } - - @Override - public String getCanonicalString() { - return operator.getCanonicalString(); - } - - @Override - public int getOperatorPrecedence() { - return operator.getOperatorPrecedence(); - } - - @Override - public boolean isHigherPrecedenceThan(final Operator operator) { - return operator.getOperatorPrecedence() < getOperatorPrecedence(); - } - - @Override - public boolean isEqualOrHigherPrecedenceThan(final Operator operator) { - return operator.getOperatorPrecedence() <= getOperatorPrecedence(); - } - - @Override - public boolean canBeApplied(final MetaClass clazz) { - return operator.canBeApplied(clazz); - } - - @Override - public void assertCanBeApplied(final MetaClass clazz) { - operator.assertCanBeApplied(clazz); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/AssignmentOperator.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/AssignmentOperator.java deleted file mode 100644 index bb07ed3d490..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/AssignmentOperator.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public enum AssignmentOperator implements Operator { - Assignment ("=", 0), - PreIncrementAssign ("+=", 0, CharSequence.class, Number.class), - PostIncrementAssign ("=+", 0, CharSequence.class, Number.class), - PreDecrementAssign ("-=", 0, Number.class), - PostDecrementAssign ("=-", 0, Number.class); - - private final Operator operator; - - AssignmentOperator(final String canonicalString, - final int operatorPrecedence, - final Class... constraints) { - - operator = new OperatorImpl(canonicalString, operatorPrecedence, constraints); - } - - @Override - public String getCanonicalString() { - return operator.getCanonicalString(); - } - - @Override - public int getOperatorPrecedence() { - return operator.getOperatorPrecedence(); - } - - @Override - public boolean isHigherPrecedenceThan(final Operator op) { - return op.getOperatorPrecedence() < getOperatorPrecedence(); - } - - @Override - public boolean isEqualOrHigherPrecedenceThan(final Operator op) { - return op.getOperatorPrecedence() <= getOperatorPrecedence(); - } - - @Override - public boolean canBeApplied(final MetaClass clazz) { - return operator.canBeApplied(clazz); - } - - @Override - public void assertCanBeApplied(final MetaClass clazz) { - operator.assertCanBeApplied(clazz); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/BitwiseOperator.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/BitwiseOperator.java deleted file mode 100644 index 02fb1a9f061..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/BitwiseOperator.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Mike Brock - */ -public enum BitwiseOperator implements Operator { - And("&", 6), - Or("|", 4), - Xor("^", 5), - ShiftRight(">>", 9), - UnsignedShiftRight(">>>", 9), - ShiftLeft("<<", 9); - - private final Operator operator; - - BitwiseOperator(final String canonicalString, final int operatorPrecedence) { - operator = new OperatorImpl(canonicalString, operatorPrecedence); - } - - @Override - public String getCanonicalString() { - return operator.getCanonicalString(); - } - - @Override - public int getOperatorPrecedence() { - return operator.getOperatorPrecedence(); - } - - @Override - public boolean isHigherPrecedenceThan(final Operator operator) { - return operator.getOperatorPrecedence() < getOperatorPrecedence(); - } - - @Override - public boolean isEqualOrHigherPrecedenceThan(final Operator operator) { - return operator.getOperatorPrecedence() <= getOperatorPrecedence(); - } - - @Override - public boolean canBeApplied(final MetaClass clazz) { - return operator.canBeApplied(clazz); - } - - @Override - public void assertCanBeApplied(final MetaClass clazz) { - operator.assertCanBeApplied(clazz); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/BlockStatement.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/BlockStatement.java deleted file mode 100644 index 22adac3b55b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/BlockStatement.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.jboss.errai.codegen.builder.ClosedBlock; -import org.jboss.errai.codegen.util.EmptyStatement; - -/** - * Represents a code block (e.g. a loop body). - * - * @author Christian Sadilek - */ -public class BlockStatement extends AbstractStatement { - public static final BlockStatement EMPTY_BLOCK = new BlockStatement() { - @Override - public BlockStatement addStatement(final Statement statement) { - throw new UnsupportedOperationException("this is an immutable object"); - } - - @Override - public void insertBefore(final Statement statement) { - throw new UnsupportedOperationException("this is an immutable object"); - } - }; - - private final List statements = new ArrayList(20); - - public BlockStatement(final Statement... statements) { - if (statements != null) { - for (final Statement statement : statements) { - if (statement != null) - this.statements.add(statement); - } - } - } - - public BlockStatement addStatement(final Statement statement) { - if (statement != null) - statements.add(statement); - - return this; - } - - public BlockStatement addAllStatements(final Collection stmts) { - if (statements != null) - statements.addAll(stmts); - - return this; - } - - public void insertBefore(final Statement statement) { - if (statement != null) { - final int pos = statements.size() == 0 ? 0 : statements.size() - 1; - statements.add(pos, statement); - } - - } - - String generatedCache; - @Override - public String generate(final Context context) { - if (generatedCache != null) return generatedCache; - - final StringBuilder buf = new StringBuilder(512); - - boolean isLastBlock = false; - for (final Statement statement : statements) { - if (buf.length() != 0 && !(statement instanceof EmptyStatement)) { - buf.append("\n"); - } - - buf.append(statement.generate(context)); - - if (!(statement instanceof Comment) && !(statement instanceof EmptyStatement) - && !buf.toString().endsWith(";") && !buf.toString().endsWith(":") && !buf.toString().endsWith("}")) { - - buf.append(";"); - } - - isLastBlock = statement instanceof ClosedBlock; - } - - if (buf.length() != 0 && buf.charAt(buf.length() - 1) != ';' && !isLastBlock) { - buf.append(';'); - } - - return generatedCache = buf.toString(); - } - - /** - * Returns a mutable representation of the statements in this block. Changes to the List returned by this - * method will be reflected in the state of this method when the code is generated. - * - * @return a list representing the underlying set of statements in this block. - */ - public List getStatements() { - return statements; - } - - public boolean isEmpty() { - return statements.isEmpty(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/BooleanExpression.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/BooleanExpression.java deleted file mode 100644 index 94f08fa96bc..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/BooleanExpression.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -/** - * Represents a boolean expression. - * - * @author Christian Sadilek - */ -public interface BooleanExpression extends Expression { - - public BooleanExpression negate(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/BooleanOperator.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/BooleanOperator.java deleted file mode 100644 index 7bee0f0678b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/BooleanOperator.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public enum BooleanOperator implements Operator { - Or ("||", 3, Boolean.class), - And ("&&", 4, Boolean.class), - Equals ("==", 8), - NotEquals ("!=", 8), - InstanceOf ("instanceof", 9), - GreaterThanOrEqual (">=", 9, Number.class), - GreaterThan (">", 9, Number.class), - LessThanOrEqual ("<=", 9, Number.class), - LessThan ("<", 9, Number.class); - - private final Operator operator; - - BooleanOperator(final String canonicalString, - final int operatorPrecedence, - final Class... constraints) { - - operator = new OperatorImpl(canonicalString, operatorPrecedence, constraints); - } - - @Override - public String getCanonicalString() { - return operator.getCanonicalString(); - } - - @Override - public int getOperatorPrecedence() { - return operator.getOperatorPrecedence(); - } - - @Override - public boolean isHigherPrecedenceThan(final Operator operator) { - return operator.getOperatorPrecedence() < getOperatorPrecedence(); - } - - @Override - public boolean isEqualOrHigherPrecedenceThan(final Operator operator) { - return operator.getOperatorPrecedence() <= getOperatorPrecedence(); - } - - @Override - public boolean canBeApplied(final MetaClass clazz) { - return operator.canBeApplied(clazz); - } - - @Override - public void assertCanBeApplied(final MetaClass clazz) { - operator.assertCanBeApplied(clazz); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/CallParameters.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/CallParameters.java deleted file mode 100644 index 12730f62a9d..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/CallParameters.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import org.jboss.errai.codegen.literal.NullLiteral; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.mvel2.util.NullType; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public class CallParameters extends AbstractStatement { - private final List parameters; - - public CallParameters(final List parameters) { - this.parameters = parameters; - } - - public static CallParameters fromStatements(final Statement... statements) { - return new CallParameters(Arrays.asList(statements)); - } - - - public static CallParameters none() { - return new CallParameters(Collections.emptyList()); - } - - public MetaClass[] getParameterTypes() { - final MetaClass[] parameterTypes = new MetaClass[parameters.size()]; - for (int i = 0; i < parameters.size(); i++) { - if (parameters.get(i) instanceof NullLiteral) { - parameterTypes[i] = MetaClassFactory.get(NullType.class); - } - else if ((parameterTypes[i] = parameters.get(i).getType()) == null) { - parameterTypes[i] = MetaClassFactory.get(Object.class); - } - - } - return parameterTypes; - } - - public List getParameters() { - return parameters; - } - - @Override - public String generate(final Context context) { - final StringBuilder buf = new StringBuilder("("); - for (int i = 0; i < parameters.size(); i++) { - String parm = parameters.get(i).generate(context).trim(); - - if (parm.endsWith(";")) { - parm = parm.substring(0, parm.length() - 1); - } - - buf.append(parm); - - if (i + 1 < parameters.size()) { - buf.append(", "); - } - } - return buf.append(")").toString(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/Cast.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/Cast.java deleted file mode 100644 index e654adc2ca2..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/Cast.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -import org.jboss.errai.codegen.builder.callstack.LoadClassReference; -import org.jboss.errai.codegen.exception.InvalidTypeException; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.common.client.api.Assert; -import org.mvel2.util.NullType; - -/** - * Implements code generation of type casting statements. - * - * @author Mike Brock - * @author Christian Sadilek - * @author Jonathan Fuerth - */ -public class Cast implements Statement { - private final MetaClass toType; - private final Statement statement; - - private Cast(final MetaClass toType, - final Statement statement) { - - this.toType = Assert.notNull(toType); - this.statement = statement; - } - - public static Statement to(final Class cls, - final Statement stmt) { - - return to(MetaClassFactory.get(cls), stmt); - } - - public static Cast to(final MetaClass cls, - final Statement stmt) { - - return new Cast(cls, stmt); - } - - @Override - public String generate(final Context context) { - final String stmt = statement.generate(context); - - if (!toType.isPrimitive() && !toType.isAssignableFrom(statement.getType()) - && !toType.isAssignableTo(statement.getType()) && !toType.isInterface() - && !statement.getType().asBoxed().equals(toType)) { - - if (context.isPermissiveMode()) { - return "(" + LoadClassReference.getClassReference(toType, context) + ") " + stmt; - } - else { - throw new InvalidTypeException(statement.getType() + " cannot be cast to " + toType); - } - } - else if (toType.isAssignableFrom(statement.getType()) && !statement.getType().equals(MetaClassFactory.get(NullType.class))) { - return stmt; - } - else { - return "(" + LoadClassReference.getClassReference(toType, context) + ") " + stmt; - } - } - - @Override - public MetaClass getType() { - return toType; - } - - @Override - public String toString() { - return "((" + toType.getFullyQualifiedName() + ")" + statement.toString() + ")"; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/Comment.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/Comment.java deleted file mode 100644 index a0795713786..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/Comment.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; - -/** - * @author Mike Brock - */ -public class Comment implements Statement { - private final String comment; - - public Comment(final String comment) { - this.comment = comment.trim(); - } - - @Override - public String generate(final Context context) { - final StringBuilder sb = new StringBuilder("// "); - for (int i = 0; i < comment.length(); i++) { - switch (comment.charAt(i)) { - case '\r': - continue; - case '\n': - sb.append('\n').append("// "); - continue; - default: - sb.append(comment.charAt(i)); - } - } - return sb.toString(); - } - - @Override - public MetaClass getType() { - return MetaClassFactory.get(void.class); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/Context.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/Context.java deleted file mode 100644 index 2729d4eea11..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/Context.java +++ /dev/null @@ -1,749 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; - -import org.jboss.errai.codegen.control.branch.Label; -import org.jboss.errai.codegen.control.branch.LabelReference; -import org.jboss.errai.codegen.exception.OutOfScopeException; -import org.jboss.errai.codegen.literal.LiteralValue; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.meta.MetaField; -import org.jboss.errai.codegen.meta.MetaMethod; -import org.jboss.errai.codegen.util.GenUtil; -import org.jboss.errai.common.client.api.Assert; - -/** - * This class represents a context in which {@link Statement}s are generated. - *

- * Its main purpose is to support the concept of scopes so that {@link Statement}s can be validated prior to - * compilation. - * - * @author Christian Sadilek - * @author Mike Brock - */ -public class Context { - private final Thread BLESSED_THREAD = Thread.currentThread(); - - private void checkThread() { - if (Thread.currentThread() != BLESSED_THREAD) { - throw new RuntimeException("WRONG THREAD!! Expected " + BLESSED_THREAD + "; got " + Thread.currentThread()); - } - } - private Context parent = null; - - private Map variables; - private Map labels; - - private boolean autoImportActive = false; - private Map imports; - private final Set classContexts; - - private final Set literalizableClasses; - - private List interningCallbackList; - private Map internedValues; - private Map> renderingCache; - - private boolean permissiveMode = GenUtil.isPermissiveMode(); - private final Set missingSymbols = new HashSet(); - - - private Context() { - classContexts = new HashSet(); - renderingCache = new HashMap>(); - literalizableClasses = new HashSet(); - internedValues = new HashMap(); - interningCallbackList = new ArrayList(); - } - - private Context(final Context parent) { - this(); - this.parent = parent; - this.autoImportActive = parent.autoImportActive; - this.imports = parent.imports; - this.renderingCache = parent.renderingCache; - - interningCallbackList = parent.interningCallbackList; - internedValues = parent.internedValues; - } - - /** - * Creates a new and empty context. - * - * @return empty context - */ - public static Context create() { - return new Context(); - } - - /** - * Create a new sub context for the given parent context. - * - * @param parent - * the parent context to use. - * - * @return Created sub context - */ - public static Context create(final Context parent) { - return new Context(parent); - } - - /** - * Add a variable to the current scope. - * - * @param name - * the name of the variable, must not be null. - * @param type - * the type of the variable, must not be null. - * - * @return the current context with the variable added. - */ - public Context addVariable(final String name, final Class type) { - checkThread(); - return addVariable(Variable.create(Assert.notNull(name), Assert.notNull(type))); - } - - /** - * Add a variable to the current scope and initialize it. - * - * @param name - * the name of the variable, must not be null. - * @param type - * the type of the variable, must not be null. - * @param initialization - * the {@link Statement} or literal value to initialize the {@link Variable}, can be null. - * - * @return the current context with the variable added. - */ - public Context addVariable(final String name, final Class type, final Object initialization) { - checkThread(); - final Variable v = Variable.create(Assert.notNull(name), Assert.notNull(type), initialization); - return addVariable(v); - } - - /** - * Add a {@link Variable} to the current scope. - * - * @param variable - * the variable instance to add, must not be null. - * - * @return the current context with the variable added. - */ - public Context addVariable(final Variable variable) { - checkThread(); - if (variables == null) - variables = new HashMap(); - - variables.put(variable.getName(), variable); - return this; - } - - /** - * Add a {@link Label} to the current scope. - * - * @param label - * the label instance to add, must not be null. - * - * @return the current context with the label added. - */ - public Context addLabel(final Label label) { - checkThread(); - if (labels == null) - labels = new HashMap(); - - labels.put(label.getName(), label); - return this; - } - - // Ensures that imports are visible/shared between all parent/child contexts. - private void initImports() { - checkThread(); - if (imports == null) { - Context c = this; - Map importsMap = null; - - while (c.parent != null) { - c = c.parent; - if (c.imports != null) - importsMap = c.imports; - } - - if (importsMap == null) { - imports = importsMap = new HashMap(); - - c = this; - while (c.parent != null) { - (c = c.parent).imports = importsMap; - } - } - else { - imports = importsMap; - } - } - } - - /** - * Imports the given class. - * - * @param clazz - * the class to import, must not be null. If it is an array type (of any number of dimensions), its non-array - * component type will be imported. - * - * @return the current context with the import added. - */ - public Context addImport(MetaClass clazz) { - checkThread(); - initImports(); - - while (clazz.isArray()) { - clazz = clazz.getComponentType(); - } - - if (!imports.containsKey(clazz.getName())) { - final String imp = getImportForClass(clazz); - if (imp != null) { - imports.put(clazz.getName(), imp); - } - } - - return this; - } - - /** - * Checks whether the given class has been imported. - * - * @param clazz - * the class to check, must not be null. - * - * @return true if import exists, otherwise false. - */ - public boolean hasImport(MetaClass clazz) { - checkThread(); - if (clazz.isArray()) { - clazz = clazz.getComponentType(); - } - - return imports != null && imports.containsKey(clazz.getName()) && - imports.get(clazz.getName()).equals(getImportForClass(clazz)); - } - - private String getImportForClass(final MetaClass clazz) { - checkThread(); - String imp = null; - - final String fqcn = clazz.getCanonicalName(); - final int idx = fqcn.lastIndexOf('.'); - if (idx != -1) { - imp = fqcn.substring(0, idx); - } - - return imp; - } - - /** - * Returns all imports except the optional ones (java.lang.*). - * - * @return required imports - */ - public Set getRequiredImports() { - checkThread(); - if (imports == null) - return Collections.emptySet(); - - final Set importedClasses = new TreeSet(); - - imports.keySet().stream() - .filter(clsName -> !imports.get(clsName).equals("java.lang")) - .forEach(clsName -> importedClasses.add(imports.get(clsName) + "." + clsName)); - return importedClasses; - } - - /** - * Enables automatic import of classes used during code generation. - * - * @return the current context whit auto import enabled. - */ - public Context autoImport() { - checkThread(); - this.autoImportActive = true; - return this; - } - - /** - * Returns a reference to the {@link Variable} with the given name. - * - * @param name - * the name of the variable. - * - * @return the {@link VariableReference} found, can not be null. - * - * @throws OutOfScopeException - * if variable with the given name can not be found. - */ - public VariableReference getVariable(final String name) { - checkThread(); - return getVariable(name, false); - } - - /** - * Returns a reference to the class member {@link Variable} with the given name. - * - * @param name - * the name of the class member variable. - * - * @return the {@link VariableReference} found, can not be null. - * - * @throws OutOfScopeException - * if member variable with the given name can not be found. - */ - public VariableReference getClassMember(final String name) { - checkThread(); - return getVariable(name, true); - } - - private VariableReference getVariable(final String name, final boolean mustBeClassMember) { - checkThread(); - Variable found = null; - Context ctx = this; - do { - if (ctx.variables != null) { - final Variable var = ctx.variables.get(name); - found = (mustBeClassMember && var != null && !variables.containsKey(var.getName())) ? null : var; - } - } - while (found == null && (ctx = ctx.parent) != null); - - if (found == null) { - missingSymbols.add(name); - if (GenUtil.isPermissiveMode()) { - return Variable.create(name, Object.class).getReference(); - } - else { - throw new OutOfScopeException((mustBeClassMember) ? "this." + name : name + " not found.\nScope:\n" + this); - } - } - - return found.getReference(); - } - - /** - * Returns the a reference to the {@link Label} with the given name. - * - * @param name - * the name of the label. - * - * @return the {@link LabelReference} found, can not be null. - * - * @throws OutOfScopeException - * if label with the given name can not be found. - */ - public LabelReference getLabel(final String name) { - checkThread(); - Label found = null; - Context ctx = this; - do { - if (ctx.labels != null) { - found = ctx.labels.get(name); - } - } - while (found == null && (ctx = ctx.parent) != null); - - if (found == null) { - throw new OutOfScopeException("Label not found: " + name); - } - - return found.getReference(); - } - - /** - * Checks is the given {@link Variable} is in scope. - * - * @param variable - * the variable to check. - * - * @return true if in scope, otherwise false. - */ - public boolean isScoped(final Variable variable) { - checkThread(); - Context ctx = this; - do { - if (ctx.variables != null && ctx.variables.containsValue(variable)) - return true; - } - while ((ctx = ctx.parent) != null); - return false; - } - - /** - * Checks is the given {@link MetaMethod} is in scope (part of the attached class contexts). - * - * @param method - * the method to check. - * - * @return true if in scope, otherwise false. - */ - public boolean isInScope(final MetaMethod method) { - checkThread(); - Context c = this; - do { - for (final MetaClass clazz : c.classContexts) { - for (final MetaMethod m : clazz.getDeclaredMethods()) { - if (m.equals(method)) - return true; - } - } - } - while ((c = c.parent) != null); - - return false; - } - - /** - * Checks is the given {@link MetaField} is in scope (part of the attached class contexts). - * - * @param field - * the field to check. - * - * @return true if in scope, otherwise false. - */ - public boolean isInScope(final MetaField field) { - checkThread(); - Context c = this; - do { - for (final MetaClass clazz : c.classContexts) { - for (final MetaField m : clazz.getDeclaredFields()) { - if (m.equals(field)) - return true; - } - } - } - while ((c = c.parent) != null); - - return false; - } - - /** - * Checks if the the given variable name is ambiguous in this scope. - * - * @param varName - * the variable name to check. - * - * @return true if ambiguous, otherwise false. - */ - public boolean isAmbiguous(final String varName) { - checkThread(); - Context ctx = this; - int matches = 0; - do { - if (ctx.variables != null && ctx.variables.containsKey(varName)) - matches++; - } - while ((ctx = ctx.parent) != null); - return matches > 1; - } - - /** - * Returns all variables in this scope (does not include variables of parent scopes). - * - * @return collection of {@link Variable}, empty if no variables are in scope. - */ - public Collection getDeclaredVariables() { - checkThread(); - if (variables == null) - return Collections.emptyList(); - return variables.values(); - } - - public void addLiteralizableClasses(final Collection> clazzes) { - checkThread(); - for (final Class cls : clazzes) { - addLiteralizableClass(cls); - } - } - - public void addLiteralizableMetaClasses(final Collection clazzes) { - checkThread(); - for (final MetaClass cls : clazzes) { - addLiteralizableClass(cls); - } - } - - /** - * Mark a class "literalizable". Meaning that all classes that are assignable to this type, are candidates for - * reification to code snapshots for this context and all subcontexts. See {@link SnapshotMaker} for further details. - * - * @param clazz - * the class, interface or superclass to be considered literalizable. - */ - public void addLiteralizableClass(final Class clazz) { - checkThread(); - addLiteralizableClass(MetaClassFactory.get(clazz)); - } - - /** - * Mark a class "literalizable". Meaning that all classes that are assignable to this type, are candidates for - * reification to code snapshots for this context and all subcontexts. See {@link SnapshotMaker} for further details. - * - * @param clazz - * the class, interface or superclass to be considered literalizable. - */ - public void addLiteralizableClass(final MetaClass clazz) { - checkThread(); - literalizableClasses.add(clazz.getErased()); - } - - /** - * Returns true if the specified class is literalizable. - * - * @param clazz - * the class, interface or superclass to be tested if literalizable - * - * @return true if the specified class is literalizable - * - * @see #addLiteralizableClass(Class) - */ - public boolean isLiteralizableClass(final Class clazz) { - checkThread(); - return isLiteralizableClass(MetaClassFactory.get(clazz)); - } - - /** - * Returns true if the specified class is literalizable. - * - * @param clazz - * the class, interface or superclass to be tested if literalizable - * - * @return true if the specified class is literalizable - * - * @see #addLiteralizableClass(MetaClass) - */ - public boolean isLiteralizableClass(final MetaClass clazz) { - checkThread(); - return getLiteralizableTargetType(clazz) != null; - } - - /** - * Returns the literalizable target type for any matching subtype. Meaning, that if say, the type - * is a subtype of the interface com.bar.Foo, which is itself marked literalizable, - * this method will return a reference to the java.lang.Class instance for com.bar.Foo - * - * @param clazz - * the class, interface or superclass to obtain a literalizable target type for. - * @param clazz - * . If there are no matches, returns null. - * - * @return the literalizable target type that matches - */ - public Class getLiteralizableTargetType(final Class clazz) { - checkThread(); - return getLiteralizableTargetType(MetaClassFactory.get(clazz)); - } - - /** - * Returns the literalizable target type for any matching subtype. Meaning, that if say, the type - * com.bar.FooImpl is a subtype of the interface com.bar.Foo, which is itself marked literalizable, - * this method will return a reference to the java.lang.Class instance for com.bar.Foo - * - * @param clazz - * the class, interface or superclass to obtain a literalizable target type for. - * @param clazz - * . If there are no matches, returns null. - * - * @return the literalizable target type that matches - */ - public Class getLiteralizableTargetType(final MetaClass clazz) { - checkThread(); - Context ctx = this; - do { - MetaClass cls = clazz; - do { - if (ctx.literalizableClasses.contains(cls)) - return cls.asClass(); - - for (final MetaClass iface : cls.getInterfaces()) { - if (ctx.literalizableClasses.contains(iface)) - return iface.asClass(); - } - } - while ((cls = cls.getSuperClass()) != null); - } - while ((ctx = ctx.parent) != null); - - return null; - } - - /** - * Returns all variables in this scope (does not include variables of parent scopes). - * - * @return map of variable name to {@link Variable}, empty if no variables are in scope. - */ - public Map getVariables() { - checkThread(); - if (variables == null) - return Collections.emptyMap(); - - return Collections.unmodifiableMap(variables); - } - - /** - * Attaches a class to the current scope. - * - * @param clazz - * class to attach. - */ - public void attachClass(final MetaClass clazz) { - checkThread(); - this.classContexts.add(clazz); - } - - /** - * Checks if automatic import is active. - * - * @return true if auto import active, otherwise false. - */ - public boolean isAutoImportActive() { - checkThread(); - return autoImportActive; - } - - /** - * Check is permissive mode is active for this context. - * - * @return - */ - public boolean isPermissiveMode() { - checkThread(); - return permissiveMode; - } - - /** - * Sets permissive mode active for this context. - * - * @param permissiveMode - */ - public void setPermissiveMode(final boolean permissiveMode) { - checkThread(); - this.permissiveMode = permissiveMode; - } - - // TODO factor this out. should not be part of Context. - @SuppressWarnings("unchecked") - public Map getRenderingCache(final RenderCacheStore store) { - checkThread(); - Map cacheStore = (Map) renderingCache.get(store.getName()); - if (cacheStore == null) { - renderingCache.put(store.getName(), (Map) (cacheStore = new HashMap())); - } - return cacheStore; - } - - /** - * Adds an {@link InterningCallback} to the context. Multiple callbacks can be registered. But, in the event that - * multiple callbacks fire and intern the same values, the last callback fired will be the effective - * interning behavior. - * - * @param interningCallback - */ - public void addInterningCallback(final InterningCallback interningCallback) { - checkThread(); - interningCallbackList.add(interningCallback); - } - - public Statement intern(final LiteralValue literalValue) { - checkThread(); - if (interningCallbackList.isEmpty()) return null; - - Statement internedReference; - - if ((internedReference = internedValues.get(literalValue.getValue())) != null) { - return internedReference; - } - - for (final InterningCallback interningCallback : interningCallbackList) { - internedReference = interningCallback.intern(literalValue); - if (internedReference != null) { - internedValues.put(literalValue.getValue(), internedReference); - } - } - return internedReference; - } - - @Override - public String toString() { - checkThread(); - String indent = ""; - final StringBuilder context = new StringBuilder(); - - Context ctx = this; - do { - if (ctx.variables != null && !ctx.variables.isEmpty()) { - context.append("Variables:\n"); - for (final String varName : ctx.variables.keySet()) { - context.append(indent).append(ctx.variables.get(varName)).append("\n"); - } - } - - if (ctx.labels != null && !ctx.labels.isEmpty()) { - context.append("Labels:\n"); - for (final String labelName : ctx.labels.keySet()) { - context.append(indent).append(ctx.labels.get(labelName)).append("\n"); - } - } - - if (ctx.classContexts != null && !ctx.classContexts.isEmpty()) { - context.append("Classes:\n"); - for (final MetaClass clazz : ctx.classContexts) { - context.append(indent).append(clazz.getFullyQualifiedName()).append("\n"); - } - } - - if (ctx.imports != null && !ctx.imports.isEmpty()) { - context.append("Imports:\n"); - for (final String className : ctx.imports.keySet()) { - context.append(indent).append(ctx.imports.get(className)).append(".").append(className).append("\n"); - ; - } - } - - indent += " "; - } - while ((ctx = ctx.parent) != null); - - return context.toString(); - } - - public Set getMissingSymbols() { - checkThread(); - return Collections.unmodifiableSet(missingSymbols); - } - -} \ No newline at end of file diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/DefModifiers.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/DefModifiers.java deleted file mode 100644 index d717bb4f16f..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/DefModifiers.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -import java.util.Arrays; -import java.util.Set; -import java.util.TreeSet; - -import org.jboss.errai.codegen.builder.Builder; - -/** - * @author Mike Brock - */ -public class DefModifiers implements Builder { - private final Set modifiers = new TreeSet(); - - public DefModifiers() { - } - - public DefModifiers(final Modifier... modifiers) { - addModifiers(modifiers); - } - - public static DefModifiers of(final Modifier... modifiers) { - final DefModifiers m = new DefModifiers(); - m.addModifiers(modifiers); - return m; - } - - public static DefModifiers none() { - return new DefModifiers(); - } - - public DefModifiers addModifiers(final Modifier... modifier) { - modifiers.addAll(Arrays.asList(modifier)); - return this; - } - - public boolean hasModifier(final Modifier modifier) { - return modifiers.contains(modifier); - } - - @Override - public String toJavaString() { - final StringBuilder stringBuilder = new StringBuilder(128); - modifiers.stream().forEach(m -> stringBuilder.append(m.getCanonicalString()).append(" ")); - return stringBuilder.toString().trim(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/DefParameters.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/DefParameters.java deleted file mode 100644 index 8b2ed8010c5..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/DefParameters.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaMethod; -import org.jboss.errai.codegen.meta.MetaParameter; - -/** - * @author Mike Brock - */ -public class DefParameters extends AbstractStatement { - private final List parameters; - - private DefParameters(final List parameters) { - this.parameters = parameters; - } - - public static DefParameters from(final MetaMethod method) { - final List parameters = new ArrayList(); - - int i = 0; - for (final MetaParameter parm : method.getParameters()) { - parameters.add(Parameter.of(parm.getType(), "a" + i++)); - } - return new DefParameters(parameters); - } - - public static DefParameters from(final MetaMethod method, final Parameter... parms) { - final List parameters = new ArrayList(); - - int i = 0; - for (final MetaParameter parm : method.getParameters()) { - parameters.add(Parameter.of(parm.getType(), parms[i].getName(), parms[i++].isFinal())); - } - return new DefParameters(parameters); - } - - public static DefParameters fromParameters(final List statements) { - return new DefParameters(statements); - } - - public static DefParameters fromParameters(final Parameter... statements) { - return new DefParameters(Arrays.asList(statements)); - } - - public static DefParameters fromTypeArray(final MetaClass... types) { - return fromTypeArray("a", types); - } - - public static DefParameters fromTypeArray(final String prefix, final MetaClass... types) { - final List parms = new ArrayList(); - int idx = 0; - - for (final MetaClass metaClass : types) { - parms.add(Parameter.of(metaClass, prefix + idx++)); - } - - return new DefParameters(parms); - } - - public static DefParameters of(final Parameter... parms) { - return new DefParameters(Arrays.asList(parms)); - - } - - public static DefParameters none() { - return new DefParameters(Collections.emptyList()); - } - - public List getParameters() { - return parameters; - } - - @Override - public String generate(final Context context) { - final StringBuilder buf = new StringBuilder("("); - for (int i = 0; i < parameters.size(); i++) { - buf.append(parameters.get(i).generate(context)); - - if (i + 1 < parameters.size()) { - buf.append(", "); - } - } - return buf.append(")").toString(); - } - - @Override - public String toString() { - final StringBuilder buf = new StringBuilder("("); - for (int i = 0; i < parameters.size(); i++) { - buf.append(parameters.get(i).getType().getFullyQualifiedName()) - .append(' ').append(parameters.get(i).getName()); - - if (i + 1 < parameters.size()) { - buf.append(", "); - } - } - return buf.append(")").toString(); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/Expression.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/Expression.java deleted file mode 100644 index 38e44e3ced2..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/Expression.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -/** - * Represents an expression. The LHS can either be a {@link Statement} - * or the generated {@link String} thereof. - * - * @param the type of operator to be used for the expression. - * - * @author Christian Sadilek - */ -public interface Expression extends Statement { - - public Statement getLhs(); - public void setLhs(Statement lhs); - - public String getLhsExpr(); - public void setLhsExpr(String lhsExpr); - - public Statement getRhs(); - public void setRhs(Statement rhs); - - public T getOperator(); - public void setOperator(T operator); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/InnerClass.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/InnerClass.java deleted file mode 100644 index f6e2c9d4563..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/InnerClass.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.impl.build.BuildMetaClass; - -/** - * Represents an inner class. - * - * @author Christian Sadilek - */ -public class InnerClass { - - private BuildMetaClass clazz = null; - - public InnerClass(final BuildMetaClass clazz) { - this.clazz = clazz; - this.clazz.setInner(true); - } - - public String generate(final Context context) { - clazz.setContext(Context.create(context)); - return clazz.toJavaString(); - } - - public MetaClass getType() { - return clazz; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/InterningCallback.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/InterningCallback.java deleted file mode 100644 index c7f5c20fd7b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/InterningCallback.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -import org.jboss.errai.codegen.literal.LiteralValue; - -/** - * An InternCallback can be registered with {@link Context#addInterningCallback(InterningCallback)}. - *

- * Some care should be taken in implementing a callback considering the recursive nature of code generation - * within the framework. For instance, the following code will produce undesirable results: - * {code} - * new InterningCallback() { - * public Statement intern(LiteralValue<?> literalValue) { - * if (literalValue instanceof StringLiteral) { - * final String varName = "stringLiteral_" + literalValue.getValue().hashCode(); - * getClassBuilder().publicField(varName, String.class) - * .initializesWith(literalValue.getValue()); - * - * return Refs.get(varName); - * } - * return null; - * } - * } - * {code} - * On the surface, the above seems like a reasonable enough implementation. But there is a recursion problem - * hidden in it. Because we initialize the field with the string value in the default manner, the value will - * be obtained from the {@link org.jboss.errai.codegen.literal.LiteralFactory} in the regular manner, and the - * interned value will reference itself! - *

- * You'll end up with code which looks like this: - * {code} - * stringLiteral_382389210 = stringLiteral_382389210; - * {code} - * ... And it's fair to say the compiler will not like this. - *

- * Instead, you should create non-recursive constructs. We can fix the above code like so: - * {code} - * new InterningCallback() { - * public Statement intern(final LiteralValue<?> literalValue) { - * if (literalValue instanceof StringLiteral) { - * final String varName = "stringLiteral_" + literalValue.getValue().hashCode(); - * getClassBuilder().publicField(varName, String.class) - * .initializesWith( - * new Statement() { - * public String generate(Context context) { - * return new StringLiteral(literalValue.getValue()).getCanonicalString(context); - * } - * - * public MetaClass getType() { - * return literalValue.getType(); - * } - * } - * ); - * - * return Refs.get(varName); - * } - * return null; - * } - * } - * {code} - * - * @author Mike Brock - */ -public interface InterningCallback { - /** - * Intern the supplied {@link LiteralValue}. This interface allows you to implement an interning strategy for - * literal values within the code generator framework. For instance, having literalized annotations render - * to a final field within a generated class with all subsequent references to matching annotations reference - * that field. - * - * @param literalValue the literal value to intern. - * - * @return If this method returns a non-null reference,the generator will assume this value is interned and will - * use the returned {@link Statement} for this literal in all future code generation. - */ - public Statement intern(LiteralValue literalValue); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/MethodInvocation.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/MethodInvocation.java deleted file mode 100644 index b8546a40e64..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/MethodInvocation.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -import java.util.HashMap; -import java.util.Map; - -import org.jboss.errai.codegen.builder.callstack.CallWriter; -import org.jboss.errai.codegen.literal.TypeLiteral; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.meta.MetaMethod; -import org.jboss.errai.codegen.meta.MetaParameterizedType; -import org.jboss.errai.codegen.meta.MetaType; -import org.jboss.errai.codegen.meta.MetaTypeVariable; -import org.jboss.errai.codegen.meta.MetaWildcardType; -import org.mvel2.util.NullType; - -/** - * Represents a method invocation statement. - * - * @author Christian Sadilek - * @author Mike Brock - */ -public class MethodInvocation extends AbstractStatement { - private final MetaClass inputType; - private final MetaMethod method; - private final CallParameters callParameters; - private Map typeVariables; - private final CallWriter writer; - - public MethodInvocation(final CallWriter writer, - final MetaClass inputType, - final MetaMethod method, - final CallParameters callParameters) { - - this.inputType = inputType; - this.method = method; - this.callParameters = callParameters; - this.writer = writer; - } - - String generatedCache; - - @Override - public String generate(final Context context) { - if (generatedCache != null) return generatedCache; - return generatedCache = method.getName().concat(callParameters.generate(context)); - } - - @Override - public MetaClass getType() { - MetaClass returnType = method.getReturnType(); - - if (method.getGenericReturnType() != null && method.getGenericReturnType() instanceof MetaTypeVariable) { - typeVariables = new HashMap(); - resolveTypeVariables(); - - final MetaTypeVariable typeVar = (MetaTypeVariable) method.getGenericReturnType(); - if (typeVariables.containsKey(typeVar.getName())) { - returnType = typeVariables.get(typeVar.getName()); - } - else if (writer.getTypeParm(typeVar.getName()) != null) { - returnType = writer.getTypeParm(typeVar.getName()); - } - else { - // returning NullType as a stand-in for an unbounded wildcard type since this is a parameterized method - // and there is not RHS qualification for the parameter. - // - // ie when calling GWT.create() and assigning it to a concrete type. - // - // TODO: might be worth flushing this out for clarify in the future. - return MetaClassFactory.get(NullType.class); - } - } - - assert returnType != null; - - return returnType; - } - - // Resolves type variables by inspecting call parameters - private void resolveTypeVariables() { - final MetaParameterizedType gSuperClass = inputType.getGenericSuperClass(); - final MetaClass superClass = inputType.getSuperClass(); - - if (superClass != null && superClass.getTypeParameters() != null && superClass.getTypeParameters().length > 0 - && gSuperClass != null && gSuperClass.getTypeParameters().length > 0) { - for (int i = 0; i < superClass.getTypeParameters().length; i++) { - final String varName = superClass.getTypeParameters()[i].getName(); - if (gSuperClass.getTypeParameters()[i] instanceof MetaClass) { - typeVariables.put(varName, (MetaClass) gSuperClass.getTypeParameters()[i]); - } - else if (gSuperClass.getTypeParameters()[i] instanceof MetaWildcardType) { - typeVariables.put(varName, MetaClassFactory.get(Object.class)); - } - else { - final MetaClass clazz = writer.getTypeParm(varName); - if (clazz != null) { - typeVariables.put(varName, clazz); - } - } - } - } - - int methodParmIndex = 0; - for (final MetaType methodParmType : method.getGenericParameterTypes()) { - final Statement parm = callParameters.getParameters().get(methodParmIndex); - - final MetaType callParmType; - if (parm instanceof TypeLiteral) { - callParmType = ((TypeLiteral) parm).getActualType(); - } - else { - callParmType = parm.getType(); - } - - resolveTypeVariable(methodParmType, callParmType); - methodParmIndex++; - } - } - - private void resolveTypeVariable(final MetaType methodParmType, final MetaType callParmType) { - if (methodParmType instanceof MetaTypeVariable) { - final MetaTypeVariable typeVar = (MetaTypeVariable) methodParmType; - final MetaClass resolvedType; - if (callParmType instanceof MetaClass) { - resolvedType = (MetaClass) callParmType; - } - else if (callParmType instanceof MetaWildcardType) { - final MetaType[] upperBounds = ((MetaWildcardType) callParmType).getUpperBounds(); - if (upperBounds != null && upperBounds.length == 1 && upperBounds[0] instanceof MetaClass) { - resolvedType = (MetaClass) upperBounds[0]; - } - else { - // it's either unbounded (? or ? super X) or has fancy bounds like ? extends X & Y - // so we'll fall back on good old java.lang.Object - resolvedType = MetaClassFactory.get(Object.class); - } - } - else { - throw new IllegalArgumentException("Call parameter \"" + callParmType + "\" is of unexpected metatype " + callParmType.getClass()); - } - typeVariables.put(typeVar.getName(), resolvedType); - } - else if (methodParmType instanceof MetaParameterizedType) { - final MetaType parameterizedCallParmType; - if (callParmType instanceof MetaParameterizedType) { - parameterizedCallParmType = callParmType; - } - else { - parameterizedCallParmType = ((MetaClass) callParmType).getParameterizedType(); - } - - final MetaParameterizedType parameterizedMethodParmType = (MetaParameterizedType) methodParmType; - int typeParmIndex = 0; - for (final MetaType typeParm : parameterizedMethodParmType.getTypeParameters()) { - if (parameterizedCallParmType != null) { - resolveTypeVariable(typeParm, - ((MetaParameterizedType) parameterizedCallParmType).getTypeParameters()[typeParmIndex++]); - } - } - } - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/Modifier.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/Modifier.java deleted file mode 100644 index 2eacf248c2c..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/Modifier.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -/** - * @author Mike Brock - */ -public enum Modifier implements Comparable { - Synchronized("synchronized"), - Native("native"), - JSNI("native"), - Static("static"), - Final("final"), - Abstract("abstract"), - Transient("transient"), - Volatile("volatile"); - - private final String canonicalString; - - Modifier(final String cananonicalString) { - this.canonicalString = cananonicalString; - } - - public String getCanonicalString() { - return canonicalString; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/Operator.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/Operator.java deleted file mode 100644 index 767fda03da9..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/Operator.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public interface Operator { - public String getCanonicalString(); - - public int getOperatorPrecedence(); - - public boolean isHigherPrecedenceThan(Operator operator); - - public boolean isEqualOrHigherPrecedenceThan(Operator operator); - - public boolean canBeApplied(MetaClass clazz); - - public void assertCanBeApplied(MetaClass clazz); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/OperatorImpl.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/OperatorImpl.java deleted file mode 100644 index 50cde156eac..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/OperatorImpl.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -import java.util.Arrays; - -import org.jboss.errai.codegen.exception.InvalidExpressionException; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public class OperatorImpl implements Operator { - - private final String canonicalString; - private final int operatorPrecedence; - private final MetaClass[] constraints; - - OperatorImpl(String canonicalString, int operatorPrecedence, Class... constraints) { - this.canonicalString = canonicalString; - this.operatorPrecedence = operatorPrecedence; - this.constraints = MetaClassFactory.fromClassArray(constraints); - } - - @Override - public String getCanonicalString() { - return canonicalString; - } - - @Override - public int getOperatorPrecedence() { - return operatorPrecedence; - } - - @Override - public boolean isHigherPrecedenceThan(Operator operator) { - return operator.getOperatorPrecedence() < getOperatorPrecedence(); - } - - @Override - public boolean isEqualOrHigherPrecedenceThan(Operator operator) { - return operator.getOperatorPrecedence() <= getOperatorPrecedence(); - } - - @Override - public void assertCanBeApplied(MetaClass clazz) { - if (!canBeApplied(clazz)) { - throw new InvalidExpressionException("Not a valid type for operator '" + - canonicalString + "': " + clazz.getFullyQualifiedName()); - } - } - - @Override - public boolean canBeApplied(MetaClass clazz) { - if (constraints.length == 0) return true; - return Arrays.stream(constraints).anyMatch(mc -> mc.asBoxed().isAssignableFrom(clazz.asBoxed())); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/Parameter.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/Parameter.java deleted file mode 100644 index 4df127c78b8..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/Parameter.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -import java.lang.annotation.Annotation; - -import org.jboss.errai.codegen.builder.callstack.LoadClassReference; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.meta.MetaClassMember; -import org.jboss.errai.codegen.meta.MetaParameter; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public class Parameter extends AbstractStatement { - private MetaClass type; - private String name; - private boolean isFinal; - - public Parameter(MetaClass type, String name, boolean isFinal) { - this.type = type; - this.name = name; - this.isFinal = isFinal; - } - - public static Parameter of(MetaClass type, String name) { - return new Parameter(type, name, false); - } - - public static Parameter of(Class type, String name) { - return new Parameter(MetaClassFactory.get(type), name, false); - } - - public static Parameter of(MetaClass type, String name, boolean isFinal) { - return new Parameter(type, name, isFinal); - } - - public static Parameter of(Class type, String name, boolean isFinal) { - return new Parameter(MetaClassFactory.get(type), name, isFinal); - } - - public static Parameter finalOf(MetaClass type, String name) { - return of(type, name, true); - } - - public static Parameter finalOf(Class type, String name) { - return of(type, name, true); - } - - public static Parameter of(MetaParameter metaParameter, String name) { - return Parameter.of(metaParameter.getType(), name); - } - public static Parameter finalOf(MetaParameter metaParameter, String name) { - return Parameter.of(metaParameter.getType(), name, true); - } - - public static Parameter[] of(MetaParameter[] parameters) { - Parameter[] ps = new Parameter[parameters.length]; - for (int i = 0; i < ps.length; i++) { - String name = parameters[i].getName(); - if (name == null) { - name = "a" + i; - } - - ps[i] = of(parameters[i].getType(), name); - } - return ps; - } - - String generatedCache; - - @Override - public String generate(Context context) { - if (generatedCache != null) - return generatedCache; - - generatedCache = (isFinal) ? Modifier.Final.getCanonicalString() + " " : ""; - return generatedCache += LoadClassReference.getClassReference(type, context, true) + " " + name; - } - - @Override - public MetaClass getType() { - return type; - } - - public boolean isFinal() { - return isFinal; - } - - public String getName() { - return name; - } - - public Annotation[] getAnnotations() { - return new Annotation[0]; - } - - @Override - public String toString() { - return type.getFullyQualifiedName(); - } - - public MetaParameter getMetaParameter() { - return new MetaParameter() { - @Override - public String getName() { - return name; - } - - @Override - public MetaClass getType() { - return type; - } - - @Override - public MetaClassMember getDeclaringMember() { - return null; - } - - @Override - public Annotation[] getAnnotations() { - return new Annotation[0]; - } - - @Override - public boolean isAnnotationPresent(Class annotation) { - return false; - } - - @Override - public A getAnnotation(Class annotation) { - return null; - } - }; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/ProxyMaker.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/ProxyMaker.java deleted file mode 100644 index 5779e915de3..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/ProxyMaker.java +++ /dev/null @@ -1,378 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -import java.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.jboss.errai.codegen.builder.BlockBuilder; -import org.jboss.errai.codegen.builder.ClassStructureBuilder; -import org.jboss.errai.codegen.builder.ElseBlockBuilder; -import org.jboss.errai.codegen.builder.StatementEnd; -import org.jboss.errai.codegen.builder.impl.BooleanExpressionBuilder; -import org.jboss.errai.codegen.builder.impl.ClassBuilder; -import org.jboss.errai.codegen.exception.UnproxyableClassException; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.meta.MetaMethod; -import org.jboss.errai.codegen.meta.MetaParameter; -import org.jboss.errai.codegen.meta.MetaParameterizedType; -import org.jboss.errai.codegen.meta.MetaType; -import org.jboss.errai.codegen.meta.MetaTypeVariable; -import org.jboss.errai.codegen.meta.impl.build.BuildMetaClass; -import org.jboss.errai.codegen.util.GenUtil; -import org.jboss.errai.codegen.util.If; -import org.jboss.errai.codegen.util.PrivateAccessUtil; -import org.jboss.errai.codegen.util.ProxyUtil; -import org.jboss.errai.codegen.util.Refs; -import org.jboss.errai.codegen.util.Stmt; - -import static org.jboss.errai.codegen.util.Stmt.loadVariable; -import static org.jboss.errai.codegen.util.Stmt.throw_; - -/** - * @author Mike Brock - */ -@SuppressWarnings({"rawtypes", "unchecked"}) -public class ProxyMaker { - public static final String PROXY_BIND_METHOD = "__$setProxiedInstance$"; - - private final Map>> weavingStatements; - private final Map proxyProperties; - - private ProxyMaker(final Map proxyProperties, - final Map>> weavingStatements) { - this.proxyProperties = proxyProperties; - this.weavingStatements = weavingStatements; - } - - public static BuildMetaClass makeProxy(final String proxyClassName, final Class cls) { - return makeProxy(proxyClassName, cls, "reflection"); - } - - public static BuildMetaClass makeProxy(final String proxyClassName, - final Class cls, - final String privateAccessorType) { - return makeProxy(proxyClassName, MetaClassFactory.get(cls), privateAccessorType); - } - - - public static BuildMetaClass makeProxy(final String proxyClassName, - final MetaClass toProxy) { - return makeProxy(proxyClassName, toProxy, "reflection"); - } - - public static BuildMetaClass makeProxy(final String proxyClassName, - final MetaClass toProxy, - final String privateAccessorType) { - return makeProxy(proxyClassName, toProxy, privateAccessorType, Collections.emptyMap(), - Collections.>>emptyMap()); - } - - public static BuildMetaClass makeProxy(final MetaClass toProxy, - final String privateAccessorType, - final Map>> weavingStatements) { - return makeProxy(toProxy, privateAccessorType, Collections.emptyMap(), weavingStatements); - - } - - public static BuildMetaClass makeProxy(final MetaClass toProxy, - final String privateAccessorType, - final Map proxyProperties, - final Map>> weavingStatements) { - return makeProxy( - PrivateAccessUtil.condensify(toProxy.getPackageName()) + "_" + toProxy.getName() + "_proxy", - toProxy, - privateAccessorType, proxyProperties, weavingStatements); - } - - public static BuildMetaClass makeProxy(final String proxyClassName, - final MetaClass toProxy, - final String privateAccessorType, - final Map proxyProperties, - final Map>> weavingStatements) { - return new ProxyMaker(proxyProperties, weavingStatements).make(proxyClassName, toProxy, privateAccessorType); - } - - - private final static Override OVERRIDE_ANNOTATION = new Override() { - @Override - public Class annotationType() { - return Override.class; - } - }; - - BuildMetaClass make(final String proxyClassName, - final MetaClass toProxy, - final String privateAccessorType) { - final ClassStructureBuilder builder; - - - - final boolean renderEqualsAndHash; - if (!toProxy.isInterface()) { - renderEqualsAndHash = true; - if (toProxy.isFinal()) { - throw new UnproxyableClassException(toProxy, toProxy.getFullyQualifiedName() - + " is an unproxiable class because it is final"); - } - if (!toProxy.isDefaultInstantiable()) { - throw new UnproxyableClassException(toProxy, toProxy.getFullyQualifiedName() + " must have a default " + - "no-arg constructor"); - } - - builder = ClassBuilder.define(proxyClassName, toProxy).publicScope().body(); - } - else { - renderEqualsAndHash = false; - builder = ClassBuilder.define(proxyClassName).publicScope().implementsInterface(toProxy).body(); - } - - final String proxyVar = "$$_proxy_$$"; - final String stateVar = "$$_init_$$"; - - final Set renderedMethods = new HashSet(); - - final Map typeVariableMap = new HashMap(); - final MetaParameterizedType metaParameterizedType = toProxy.getParameterizedType(); - - if (metaParameterizedType != null) { - int i = 0; - for (final MetaTypeVariable metaTypeVariable : toProxy.getTypeParameters()) { - typeVariableMap.put(metaTypeVariable.getName(), metaParameterizedType.getTypeParameters()[i++]); - } - } - - builder.privateField(proxyVar, toProxy).finish(); - - // Create state variable for tracking initialization - builder.privateField(stateVar, boolean.class).finish(); - - final Set> entries = proxyProperties.entrySet(); - for (final Map.Entry entry : entries) { - builder.privateField(entry.getValue().getEncodedProperty(), entry.getValue().getType()).finish(); - builder.packageMethod(void.class, "$set_" + entry.getKey(), Parameter.of(entry.getValue().getType(), "o")) - .append(Stmt.loadVariable(entry.getValue().getEncodedProperty()).assignValue(Refs.get("o"))) - .finish(); - } - - for (final MetaMethod method : toProxy.getMethods()) { - final String methodString = GenUtil.getMethodString(method); - if (renderedMethods.contains(methodString) || method.getName().equals("hashCode") - || method.getName().equals("clone") || method.getName().equals("finalize") - || (method.getName().equals("equals") && method.getParameters().length == 1 - && method.getParameters()[0].getType().getFullyQualifiedName().equals(Object.class.getName()))) - continue; - - renderedMethods.add(methodString); - - if ((!method.isPublic() && !method.isProtected()) || - method.isSynthetic() || - method.isFinal() || - method.isStatic() || - method.getDeclaringClass().getFullyQualifiedName().equals(Object.class.getName())) - continue; - - final List methodParms = new ArrayList(); - final MetaParameter[] parameters = method.getParameters(); - - for (int i = 0; i < parameters.length; i++) { - methodParms.add(Parameter.of(parameters[i].getType().getErased(), "a" + i)); - } - - final DefParameters defParameters = DefParameters.fromParameters(methodParms); - final BlockBuilder methBody = builder.publicMethod(method.getReturnType(), method.getName()) - .annotatedWith(OVERRIDE_ANNOTATION) - .parameters(defParameters) - .throws_(method.getCheckedExceptions()); - - // Put method body into conditional, executed only after initialization - BlockBuilder ifBody = Stmt.create().if_( - BooleanExpressionBuilder.create(Stmt.loadVariable(stateVar))); - - ifBody.appendAll(getAroundInvokeStatements(method)); - ifBody.appendAll(getBeforeStatements(method)); - - final List parms = defParameters.getParameters(); - - final Statement[] statementVars = new Statement[parms.size()]; - for (int i = 0; i < parms.size(); i++) { - statementVars[i] = loadVariable(parms.get(i).getName()); - } - - if (!method.isPublic()) { - PrivateAccessUtil.addPrivateAccessStubs(privateAccessorType, builder, method, new Modifier[0]); - - final Statement[] privateAccessStmts = new Statement[statementVars.length + 1]; - privateAccessStmts[0] = Refs.get(proxyVar); - System.arraycopy(statementVars, 0, privateAccessStmts, 1, statementVars.length); - - if (method.getReturnType().isVoid()) { - ifBody._(loadVariable("this").invoke(PrivateAccessUtil.getPrivateMethodName(method), privateAccessStmts)); - } - else { - ifBody._(loadVariable("this").invoke(PrivateAccessUtil.getPrivateMethodName(method), privateAccessStmts).returnValue()); - } - } - else { - if (method.getReturnType().isVoid()) { - ifBody._(loadVariable(proxyVar).invoke(method, statementVars)); - } - else { - ifBody._(loadVariable(proxyVar).invoke(method, statementVars).returnValue()); - } - } - - ifBody.appendAll(getAfterStatements(method)); - ifBody.appendAll(getAroundInvokeStatements(method)); - - BlockBuilder elseBody = ifBody.finish().else_(); - // Must return in else body if method is not void - if (!method.getReturnType().isVoid()) { - elseBody.append(ProxyUtil.generateProxyMethodReturnStatement(method)); - } - - methBody.append(elseBody.finish()); - methBody.finish(); - } - - if (renderEqualsAndHash) { - // implement hashCode() - builder.publicMethod(int.class, "hashCode") - .annotatedWith(OVERRIDE_ANNOTATION) - .body() - ._( - If.isNull(loadVariable(proxyVar)) - ._(throw_(IllegalStateException.class, "call to hashCode() on an unclosed proxy.")) - .finish() - .else_() - ._(Stmt.loadVariable(proxyVar).invoke("hashCode").returnValue()) - .finish() - ) - .finish(); - - // implements equals() - builder.publicMethod(boolean.class, "equals", Parameter.of(Object.class, "o")) - .annotatedWith(OVERRIDE_ANNOTATION) - .body() - ._( - If.isNull(loadVariable(proxyVar)) - ._(throw_(IllegalStateException.class, "call to equals() on an unclosed proxy.")) - .finish() - .else_() - ._(Stmt.loadVariable(proxyVar).invoke("equals", Refs.get("o")).returnValue()) - .finish() - ) - .finish(); - } - - builder.publicMethod(void.class, PROXY_BIND_METHOD).parameters(DefParameters.of(Parameter.of(toProxy, "proxy"))) - ._(loadVariable(proxyVar).assignValue(loadVariable("proxy"))) - // Set proxy state to initialized - ._(loadVariable(stateVar).assignValue(true)) - .finish(); - - return builder.getClassDefinition(); - } - - private Collection getWeavingStatements(final MetaMethod method, final WeaveType type) { - final Map> weaveTypeListMap = weavingStatements.get(method); - if (weaveTypeListMap == null) { - return Collections.emptyList(); - } - else { - final Collection statementList = weaveTypeListMap.get(type); - if (statementList == null) { - return Collections.emptyList(); - } - else { - return Collections.unmodifiableCollection(statementList); - } - } - } - - public Collection getAroundInvokeStatements(final MetaMethod method) { - return getWeavingStatements(method, WeaveType.AroundInvoke); - } - - public Collection getBeforeStatements(final MetaMethod method) { - return getWeavingStatements(method, WeaveType.BeforeInvoke); - } - - public Collection getAfterStatements(final MetaMethod method) { - return getWeavingStatements(method, WeaveType.AfterInvoke); - } - - public static Statement closeProxy(final Statement proxyReference, final Statement beanInstance) { - return Stmt.nestedCall(proxyReference).invoke(PROXY_BIND_METHOD, beanInstance); - } - - public static Collection createAllPropertyBindings(final Statement proxyRef, - final Map proxyProperties) { - final List statementList = new ArrayList(); - for (final Map.Entry entry : proxyProperties.entrySet()) { - statementList.add(Stmt.nestedCall(proxyRef).invoke("$set_" + entry.getKey(), entry.getValue().getOriginalValueReference())); - } - return statementList; - } - - public static class ProxyProperty implements Statement { - private final String propertyName; - private final MetaClass type; - private final Statement valueReference; - - public ProxyProperty(final String propertyName, final MetaClass type, final Statement valueReference) { - this.propertyName = propertyName; - this.type = type; - this.valueReference = valueReference; - } - - @Override - public MetaClass getType() { - return type; - } - - public Statement getOriginalValueReference() { - return valueReference; - } - - public Statement getProxiedValueReference() { - return Refs.get(getEncodedProperty()); - } - - private String getEncodedProperty() { - return "$P_" + propertyName + "_P$"; - } - - @Override - public String generate(Context context) { - return getEncodedProperty(); - } - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/RenderCacheStore.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/RenderCacheStore.java deleted file mode 100644 index 5a2020c93d6..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/RenderCacheStore.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - - -/** - * @author Mike Brock - */ -public interface RenderCacheStore { - public String getName(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/SnapshotMaker.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/SnapshotMaker.java deleted file mode 100644 index e3d177eec48..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/SnapshotMaker.java +++ /dev/null @@ -1,425 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashSet; -import java.util.IdentityHashMap; -import java.util.List; -import java.util.Set; - -import org.jboss.errai.codegen.builder.AnonymousClassStructureBuilder; -import org.jboss.errai.codegen.builder.ClassStructureBuilder; -import org.jboss.errai.codegen.builder.impl.ObjectBuilder; -import org.jboss.errai.codegen.exception.CyclicalObjectGraphException; -import org.jboss.errai.codegen.exception.GenerationException; -import org.jboss.errai.codegen.exception.NotLiteralizableException; -import org.jboss.errai.codegen.literal.NullLiteral; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.meta.MetaMethod; -import org.jboss.errai.codegen.util.Stmt; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static org.jboss.errai.codegen.util.PrettyPrinter.prettyPrintJava; - -//import com.google.gwt.dev.util.collect.IdentityHashSet; - -/** - * Utility class for creating code-generated snapshots of certain types of live value objects. - * The classes and interfaces that SnapshotMaker works with have the following characteristics: - *

- * - * @author Jonathan Fuerth - * @author Mike Brock - */ -public final class SnapshotMaker { - - final static Logger logger = LoggerFactory.getLogger(SnapshotMaker.class); - - /** - * Callback interface for providing custom method bodies in snapshots. There are three major use cases: - *
    - *
  1. To implement methods that take parameters (snapshots of - * these methods cannot be generated automatically) - *
  2. To return a reference to some object that's already in the - * scope of the snapshot (such as a reference to a parent object - * from a getParent() method) - *
  3. To implement additional methods in the case that the snapshot - * type is not the same as the type to extend. - *
- * - * @author Jonathan Fuerth - */ - public interface MethodBodyCallback { - - /** - * Optionally returns the statement that should be used as the body of the - * given method for the given object's snapshot. If the default snapshot - * behaviour provided by SnapshotMaker is sufficient for the given method, - * this callback can simply return null. - * - * @param method - * The method to provide the body for. - * @param o - * The instance object that we are taking the snapshot of. You can - * use this reference if you need to invoke {@code method}. - * @param containingClass - * The class that will contain the generated method. During the - * callback, you can generate additional methods and fields within - * this class if you like. - * @return The Statement to use as the method body (must return a type - * compatible with {@code method}'s return type), or null if the - * snapshot maker should generate the method body by invoking method - * on {@code o} and returning a Literal of its value. - */ - Statement generateMethodBody(MetaMethod method, Object o, ClassStructureBuilder containingClass); - - } - - /** This class should not be instantiated. */ - private SnapshotMaker() {} - - /** - * Code-generates an object whose methods return (snapshots of) the same - * values as the given object. - * - * @param o - * The object to snapshot. - * @param typeToSnapshot - * The type to read the snapshot attributes from. Must be a - * superclass of o or an interface implemented by o, and methods not - * supplied by {@code methodBodyCallback} must meed the requirements - * laid out in the class-level SnapshotMaker documentation. - * @param typeToExtend - * The type of the snapshot to produce. Must be a subclass or - * subinterface of typeToSnapshot, and the additional methods present - * in typeToExtend vs. typeToSnapshot must be provided by the - * MethodMaker callback, since they can't be generated from o. - * @param methodBodyCallback - * A callback that can provide method bodies, preventing the standard - * snapshot behaviour for those methods. This callback is optional; - * null is acceptable as "no callback." - * @param typesToRecurseOn - * The types for which the snapshot maker should be applied - * recursively. - * @return A Statement representing the value of the object - * @throws CyclicalObjectGraphException - * if any objects reachable from {@code o} form a reference cycle. - * The simplest example of this would be a method on {@code o} that - * returns {@code o} itself. You may be able to work around such a - * problem by supplying a canned representation of one of the - * objects in the cycle. - */ - public static Statement makeSnapshotAsSubclass( - final Object o, - final Class typeToSnapshot, - final Class typeToExtend, - final MethodBodyCallback methodBodyCallback, - final Class ... typesToRecurseOn) { - final MetaClass metaTypeToSnapshot = MetaClassFactory.get(typeToSnapshot); - final MetaClass metaTypeToExtend = MetaClassFactory.get(typeToExtend); - final MetaClass[] metaTypesToRecurseOn = new MetaClass[typesToRecurseOn.length]; - for (int i = 0; i < typesToRecurseOn.length; i++) { - metaTypesToRecurseOn[i] = MetaClassFactory.get(typesToRecurseOn[i]); - } - return makeSnapshotAsSubclass(o, metaTypeToSnapshot, metaTypeToExtend, methodBodyCallback, metaTypesToRecurseOn); - } - - /** - * Code-generates an object whose methods return (snapshots of) the same - * values as the given object. - * - * @param o - * The object to snapshot. - * @param typeToSnapshot - * The type to read the snapshot attributes from. Must be a - * superclass of o or an interface implemented by o, and methods not - * supplied by {@code methodBodyCallback} must meed the requirements - * laid out in the class-level SnapshotMaker documentation. - * @param typeToExtend - * The type of the snapshot to produce. Must be a subclass or - * subinterface of typeToSnapshot, and the additional methods present - * in typeToExtend vs. typeToSnapshot must be provided by the - * MethodMaker callback, since they can't be generated from o. - * @param methodBodyCallback - * A callback that can provide method bodies, preventing the standard - * snapshot behaviour for those methods. This callback is optional; - * null is acceptable as "no callback." - * @param typesToRecurseOn - * The types for which the snapshot maker should be applied - * recursively. - * @return A Statement representing the value of the object - * @throws CyclicalObjectGraphException - * if any objects reachable from {@code o} form a reference cycle. - * The simplest example of this would be a method on {@code o} that - * returns {@code o} itself. You may be able to work around such a - * problem by supplying a canned representation of one of the objects - * in the cycle. - */ - public static Statement makeSnapshotAsSubclass( - final Object o, - final MetaClass typeToSnapshot, - final MetaClass typeToExtend, - final MethodBodyCallback methodBodyCallback, - final MetaClass ... typesToRecurseOn) { - - return makeSnapshotAsSubclass( - o, - typeToSnapshot, - typeToExtend, - methodBodyCallback, - new HashSet(Arrays.asList(typesToRecurseOn)), - new IdentityHashMap(), - Collections.newSetFromMap(new IdentityHashMap())); - } - - /** - * Implementation for the same-named public methods. - * - * @param o - * The object to snapshot. - * @param typeToSnapshot - * The type to read the snapshot attributes from. Must be a - * superclass of o or an interface implemented by o, and methods not - * supplied by {@code methodBodyCallback} must meed the requirements - * laid out in the class-level SnapshotMaker documentation. - * @param typeToExtend - * The type of the snapshot to produce. Must be a subclass or - * subinterface of typeToSnapshot, and the additional methods present - * in typeToExtend vs. typeToSnapshot must be provided by the - * MethodMaker callback, since they can't be generated from o. - * @param typesToRecurseOn - * Types for which this method should be called recursively. - * @param methodBodyCallback - * A callback that can provide method bodies, preventing the standard - * snapshot behaviour for those methods. This callback is optional; - * null is acceptable as "no callback." - * @param existingSnapshots - * Object instances for which a snapshot has already been completed. - * Bootstrap this with an empty IdentityHashMap. - * @param unfinishedSnapshots - * Object instances for which a partially-completed snapshot exists. - * If one of these objects is returned by a method in {@code o}, this - * causes a CyclicalObjectGraphException. - * @return A Statement of type {@code typeToExtend} that represents the - * current publicly visible state of {@code o}. - */ - private static Statement makeSnapshotAsSubclass( - final Object o, - final MetaClass typeToSnapshot, - final MetaClass typeToExtend, - final MethodBodyCallback methodBodyCallback, - final Set typesToRecurseOn, - final IdentityHashMap existingSnapshots, - final Set unfinishedSnapshots) { - - if (o == null) { - return NullLiteral.INSTANCE; - } - - if (!typeToSnapshot.isAssignableFrom(o.getClass())) { - throw new IllegalArgumentException( - "Given object (of type " + o.getClass().getName() + - ") is not an instance of requested type to snapshot " + typeToSnapshot.getName()); - } - - if (logger.isDebugEnabled()) { - logger.debug("** Making snapshot of " + o); - logger.debug(" Existing snapshots: " + existingSnapshots); - } - - final List sortedMethods = Arrays.asList(typeToExtend.getMethods()); - Collections.sort(sortedMethods, new Comparator() { - @Override - public int compare(MetaMethod m1, MetaMethod m2) { - return m1.getName().compareTo(m2.getName()); - } - }); - - logger.debug(" Creating a new statement"); - return new Statement() { - String generatedCache; - - /** - * We retain a mapping of return values to the methods that returned them, - * in case we need to provide diagnostic information when an exception is - * thrown. - */ - IdentityHashMap methodReturnVals = new IdentityHashMap(); - - @Override - public String generate(Context context) { - if (logger.isDebugEnabled()) { - logger.debug("++ Statement.generate() for " + o); - } - - if (generatedCache != null) return generatedCache; - - // create a subcontext and record the types we will allow the LiteralFactory to create automatic - // snapshots for. - final Context subContext = Context.create(context); - subContext.addLiteralizableMetaClasses(typesToRecurseOn); - - final AnonymousClassStructureBuilder builder = ObjectBuilder.newInstanceOf(typeToExtend.getErased(), context) - .extend(); - unfinishedSnapshots.add(o); - for (final MetaMethod method : sortedMethods) { - if (method.isFinal() || method.getName().equals("toString")) continue; - - if (logger.isDebugEnabled()) { - logger.debug(" method " + method.getName()); - logger.debug(" return type " + method.getReturnType()); - } - - if (methodBodyCallback != null) { - final Statement providedMethod = methodBodyCallback.generateMethodBody(method, o, builder); - if (providedMethod != null) { - logger.debug(" body provided by callback"); - builder - .publicOverridesMethod(method.getName(), Parameter.of(method.getParameters())) - .append(providedMethod) - .finish(); - continue; - } - } - - if (method.getName().equals("equals") || method.getName().equals("hashCode") - || method.getName().equals("clone") || method.getName().equals("finalize")) { - // we skip these if not provided by the callback - if (logger.isDebugEnabled()) { - logger.debug(" skipping special-case method " + method.getName()); - } - continue; - } - - if (method.getParameters().length > 0) { - throw new GenerationException("Method " + method + " in " + typeToSnapshot + - " takes parameters. Such methods must be handled by the MethodBodyCallback," + - " because they cannot be snapshotted."); - } - - if (method.getReturnType().equals(MetaClassFactory.get(void.class))) { - builder.publicOverridesMethod(method.getName()).finish(); - if (logger.isDebugEnabled()) { - logger.debug(" finished method " + method.getName()); - } - continue; - } - try { - - final Object retval = typeToExtend.asClass().getMethod(method.getName()).invoke(o); - methodReturnVals.put(retval, method); - - if (logger.isDebugEnabled()) { - logger.debug(" retval=" + retval); - } - - Statement methodBody; - if (existingSnapshots.containsKey(retval)) { - logger.debug(" using existing snapshot"); - methodBody = existingSnapshots.get(retval); - } - else if (subContext.isLiteralizableClass(method.getReturnType().getErased())) { - if (unfinishedSnapshots.contains(retval)) { - throw new CyclicalObjectGraphException(unfinishedSnapshots); - } - - // use Stmt.create(context) to pass the context along. - if (logger.isDebugEnabled()) { - logger.debug(" >> recursing for " + retval); - } - - methodBody = Stmt.create(subContext).nestedCall(makeSnapshotAsSubclass( - retval, method.getReturnType(), method.getReturnType(), - methodBodyCallback, typesToRecurseOn, existingSnapshots, unfinishedSnapshots)).returnValue(); - } - else { - logger.debug(" relying on literal factory"); - methodBody = Stmt.load(retval).returnValue(); - } - - if (logger.isDebugEnabled()) { - logger.debug(" finished method " + method.getName()); - } - - builder.publicOverridesMethod(method.getName()).append(methodBody).finish(); - existingSnapshots.put(retval, methodBody); - } - catch (final GenerationException e) { - e.appendFailureInfo("In attempt to snapshot return value of " - + typeToExtend.getFullyQualifiedName() + "." + method.getName() + "()"); - throw e; - } - catch (final RuntimeException e) { - throw e; - } - catch (final Exception e) { - throw new GenerationException("Failed to extract value for snapshot", e); - } - } - - if (logger.isDebugEnabled()) { - logger.debug(" finished: " + builder); - } - - try { - generatedCache = prettyPrintJava(builder.finish().toJavaString()); - } catch (final NotLiteralizableException e) { - final MetaMethod m = methodReturnVals.get(e.getNonLiteralizableObject()); - if (m != null) { - e.appendFailureInfo("This value came from method " + - m.getDeclaringClass().getFullyQualifiedNameWithTypeParms() + "." + m.getName() + - ", which has return type " + m.getReturnType()); - } - throw e; - } catch (final GenerationException e) { - e.appendFailureInfo("While generating a snapshot of " + o.toString() + - " (actual type: " + o.getClass().getName() + - "; type to extend: " + typeToExtend.getFullyQualifiedName() + ")"); - throw e; - } - unfinishedSnapshots.remove(o); - return generatedCache; - } - - @Override - public MetaClass getType() { - return typeToExtend; - } - }; - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/Statement.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/Statement.java deleted file mode 100644 index 9fd8e4860d7..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/Statement.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public interface Statement { - public String generate(Context context); - - public MetaClass getType(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/StringExpression.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/StringExpression.java deleted file mode 100644 index cd9dfc8efd3..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/StringExpression.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -/** - * Represents an string expression. - * - * @author Slava Pankov - */ -public interface StringExpression extends Expression, Statement { - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/StringOperator.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/StringOperator.java deleted file mode 100644 index 3fd000d9c11..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/StringOperator.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Slava Pankov - */ -public enum StringOperator implements Operator { - - Concat ("+", 0, CharSequence.class); - - private final Operator operator; - - StringOperator(final String canonicalString, - final int operatorPrecedence, - final Class... constraints) { - - operator = new OperatorImpl(canonicalString, operatorPrecedence, constraints); - } - - @Override - public String getCanonicalString() { - return operator.getCanonicalString(); - } - - @Override - public int getOperatorPrecedence() { - return operator.getOperatorPrecedence(); - } - - @Override - public boolean isHigherPrecedenceThan(final Operator operator) { - return operator.getOperatorPrecedence() < getOperatorPrecedence(); - } - - @Override - public boolean isEqualOrHigherPrecedenceThan(final Operator operator) { - return operator.getOperatorPrecedence() <= getOperatorPrecedence(); - } - - @Override - public boolean canBeApplied(final MetaClass clazz) { - return operator.canBeApplied(clazz); - } - - @Override - public void assertCanBeApplied(final MetaClass clazz) { - operator.assertCanBeApplied(clazz); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/StringStatement.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/StringStatement.java deleted file mode 100644 index 71c6d38ac44..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/StringStatement.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; - -public class StringStatement extends AbstractStatement { - private final String statement; - private final MetaClass clazz; - - public StringStatement(final String statement) { - this(statement, null); - } - - public StringStatement(final String statement, final MetaClass returnType) { - this.statement = statement; - this.clazz = returnType; - } - - public static StringStatement of(final String statement) { - return new StringStatement(statement); - } - - public static StringStatement of(final String statement, final MetaClass returnType) { - return new StringStatement(statement, returnType); - } - - public static StringStatement of(final String statement, final Class returnType) { - return of(statement, MetaClassFactory.get(returnType)); - } - - @Override - public String generate(final Context context) { - return statement; - } - - @Override - public MetaClass getType() { - return clazz; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/TernaryStatement.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/TernaryStatement.java deleted file mode 100644 index 6149198f921..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/TernaryStatement.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Mike Brock - */ -public class TernaryStatement extends AbstractStatement { - private final BooleanExpression condition; - private final Statement trueStatement; - private final Statement falseStatement; - private MetaClass returnType; - - public TernaryStatement(final BooleanExpression condition, - final Statement trueStatement, - final Statement falseStatement) { - this.condition = condition; - this.trueStatement = trueStatement; - this.falseStatement = falseStatement; - } - - @Override - public String generate(final Context context) { - final String conditionString = condition.generate(context); - final String trueString = trueStatement.generate(context); - final String falseString = falseStatement.generate(context); - - returnType = trueStatement.getType(); - if (falseStatement.getType().isAssignableFrom(returnType)) { - returnType = falseStatement.getType(); - } - - return conditionString.concat(" ? ").concat(trueString).concat(" : ").concat(falseString); - } - - @Override - public MetaClass getType() { - return returnType; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/ThrowsDeclaration.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/ThrowsDeclaration.java deleted file mode 100644 index 51965b3f793..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/ThrowsDeclaration.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -import org.jboss.errai.codegen.builder.callstack.LoadClassReference; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; - -/** - * @author Christian Sadilek - */ -public class ThrowsDeclaration extends AbstractStatement { - private final MetaClass[] exceptionTypes; - - private ThrowsDeclaration(final MetaClass[] exceptionTypes) { - this.exceptionTypes = exceptionTypes; - } - - @SuppressWarnings("unchecked") - public static ThrowsDeclaration of(final Class... exceptionTypes) { - return new ThrowsDeclaration(MetaClassFactory.fromClassArray(exceptionTypes)); - } - - public static ThrowsDeclaration of(final MetaClass... exceptionTypes) { - return new ThrowsDeclaration(exceptionTypes); - } - - public static ThrowsDeclaration none() { - return new ThrowsDeclaration(new MetaClass[0]); - } - - public boolean isEmpty() { - return (exceptionTypes == null) || (exceptionTypes.length == 0); - } - - public MetaClass[] getExceptionTypes() { - return exceptionTypes; - } - - String generatedCache; - - @Override - public String generate(final Context context) { - if (generatedCache != null) return generatedCache; - final StringBuilder buf = new StringBuilder(128); - for (int i = 0; i < exceptionTypes.length; i++) { - if (i == 0) { - buf.append("throws "); - } - - buf.append(LoadClassReference.getClassReference(exceptionTypes[i], context)); - - if (i + 1 < exceptionTypes.length) { - buf.append(", "); - } - } - return generatedCache = buf.toString(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/UnaryOperator.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/UnaryOperator.java deleted file mode 100644 index 080bcfaab0c..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/UnaryOperator.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public enum UnaryOperator implements Operator { - New ("new", 0), - Increment ("++", 0), - Decrement ("--", 0), - Complement ("!", 0); - - private final Operator operator; - - UnaryOperator(final String canonicalString, final int operatorPrecedence) { - operator = new OperatorImpl(canonicalString, operatorPrecedence); - } - - @Override - public String getCanonicalString() { - return operator.getCanonicalString(); - } - - @Override - public int getOperatorPrecedence() { - return operator.getOperatorPrecedence(); - } - - @Override - public boolean isHigherPrecedenceThan(final Operator operator) { - return operator.getOperatorPrecedence() < getOperatorPrecedence(); - } - - @Override - public boolean isEqualOrHigherPrecedenceThan(final Operator operator) { - return operator.getOperatorPrecedence() <= getOperatorPrecedence(); - } - - @Override - public boolean canBeApplied(final MetaClass clazz) { - return operator.canBeApplied(clazz); - } - - @Override - public void assertCanBeApplied(final MetaClass clazz) { - operator.assertCanBeApplied(clazz); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/Variable.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/Variable.java deleted file mode 100644 index 1586da02d38..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/Variable.java +++ /dev/null @@ -1,399 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -import javax.enterprise.util.TypeLiteral; - -import org.jboss.errai.codegen.builder.impl.DeclareAssignmentBuilder; -import org.jboss.errai.codegen.exception.InvalidTypeException; -import org.jboss.errai.codegen.literal.LiteralFactory; -import org.jboss.errai.codegen.literal.LiteralValue; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.util.GenUtil; -import org.jboss.errai.codegen.util.Stmt; - -/** - * This class represents a variable. - *

- * Note that initialization using {@link LiteralValue}s takes effect immediately, - * initialization using {@link Statement}s needs to be deferred to generation time. - * - * @author Christian Sadilek - */ -public class Variable extends AbstractStatement { - private final String name; - private MetaClass type; - private Statement value; - - private Object initialization; - - private boolean isFinal; - - private Variable(final String name, final MetaClass type) { - this.name = name; - this.type = type; - } - - private Variable(final String name, final MetaClass type, final Object initialization) { - this(name, type); - - final LiteralValue val = LiteralFactory.isLiteral(initialization); - if (val != null) { - this.type = (type == null) ? val.getType() : type; - this.value = GenUtil.convert(Context.create(), initialization, this.type); - } - else { - // deferred initialization - this.initialization = initialization; - } - } - - public void initialize(final Object initializationValue) { - this.initialization = initializationValue; - } - - private MetaClass inferType(final Context context, final Object initialization) { - final Statement initStatement = GenUtil.generate(context, initialization); - final MetaClass inferredType = (initStatement != null) ? initStatement.getType() : null; - if (inferredType == null) { - throw new InvalidTypeException("No type specified and no initialization provided to infer the type."); - } - - return inferredType; - } - - /** - * Creates a variable, but does not assign it to a scope. If you are trying to - * declare a variable, see {@link Stmt#declareFinalVariable(String, Class)}. - * - * @param name - * The variable name - * @param type - * The variable reference type - * @return A newly created variable that is not (yet) referencable. - */ - public static Variable createFinal(final String name, final Class type) { - return createFinal(name, MetaClassFactory.get(type)); - } - - /** - * Creates a variable, but does not assign it to a scope. If you are trying to - * declare a variable, see {@link Stmt#declareFinalVariable(String, TypeLiteral)}. - * - * @param name - * The variable name - * @param type - * The variable reference type - * @return A newly created variable that is not (yet) referencable. - */ - public static Variable createFinal(final String name, final TypeLiteral type) { - final Variable variable = create(name, type); - variable.isFinal = true; - return variable; - } - - /** - * Creates a variable, but does not assign it to a scope. If you are trying to - * declare a variable, see {@link Stmt#declareFinalVariable(String, MetaClass)}. - * - * @param name - * The variable name - * @param type - * The variable reference type - * @return A newly created variable that is not (yet) referencable. - */ - public static Variable createFinal(final String name, final MetaClass type) { - final Variable variable = create(name, type); - variable.isFinal = true; - return variable; - } - - /** - * Creates a variable, but does not assign it to a scope. If you are trying to - * declare a variable, see {@link Stmt#declareFinalVariable(String, Class, Object)}. - * - * @param name - * The variable name - * @param type - * The variable reference type - * @return A newly created variable that is not (yet) referencable. - */ - public static Variable createFinal(final String name, final Class type, final Object initialization) { - return createFinal(name, MetaClassFactory.get(type), initialization); - } - - /** - * Creates a variable, but does not assign it to a scope. If you are trying to - * declare a variable, see {@link Stmt#declareFinalVariable(String, MetaClass, Object)}. - * - * @param name - * The variable name - * @param type - * The variable reference type - * @return A newly created variable that is not (yet) referencable. - */ - public static Variable createFinal(final String name, final MetaClass type, final Object initialization) { - final Variable variable = create(name, type, initialization); - variable.isFinal = true; - return variable; - } - - /** - * Creates a variable, but does not assign it to a scope. If you are trying to - * declare a variable, see {@link Stmt#declareFinalVariable(String, TypeLiteral, Object)}. - * - * @param name - * The variable name - * @param type - * The variable reference type - * @return A newly created variable that is not (yet) referencable. - */ - public static Variable createFinal(final String name, final TypeLiteral type, final Object initialization) { - final Variable variable = create(name, type, initialization); - variable.isFinal = true; - return variable; - } - - /** - * Creates a variable, but does not assign it to a scope. If you are trying to - * declare a variable, see {@link Stmt#declareVariable(String, Object)}. - * - * @param name - * The variable name - * @param type - * The variable reference type - * @return A newly created variable that is not (yet) referencable. - */ - public static Variable create(final String name, final Object initialization) { - return new Variable(name, null, initialization); - } - - public static Variable from(final VariableReference ref) { - return new Variable(ref.getName(), ref.getType()); - } - - /** - * Creates a variable, but does not assign it to a scope. If you are trying to - * declare a variable, see {@link Stmt#declareVariable(String, Class)}. - * - * @param name - * The variable name - * @param type - * The variable reference type - * @return A newly created variable that is not (yet) referencable. - */ - public static Variable create(final String name, final Class type) { - return new Variable(name, MetaClassFactory.get(type)); - } - - /** - * Creates a variable, but does not assign it to a scope. If you are trying to - * declare a variable, see {@link Stmt#declareVariable(String, TypeLiteral)}. - * - * @param name - * The variable name - * @param type - * The variable reference type - * @return A newly created variable that is not (yet) referencable. - */ - public static Variable create(final String name, final TypeLiteral type) { - return new Variable(name, MetaClassFactory.get(type)); - } - - /** - * Creates a variable, but does not assign it to a scope. If you are trying to - * declare a variable, see {@link Stmt#declareVariable(String, MetaClass)}. - * - * @param name - * The variable name - * @param type - * The variable reference type - * @return A newly created variable that is not (yet) referencable. - */ - public static Variable create(final String name, final MetaClass type) { - return new Variable(name, type); - } - - /** - * Creates a variable, but does not assign it to a scope. If you are trying to - * declare a variable, see {@link Stmt#declareVariable(String, Class, Object)}. - * - * @param name - * The variable name - * @param type - * The variable reference type - * @return A newly created variable that is not (yet) referencable. - */ - public static Variable create(final String name, final Class type, final Object initialization) { - return new Variable(name, MetaClassFactory.get(type), initialization); - } - - /** - * Creates a variable, but does not assign it to a scope. If you are trying to - * declare a variable, see {@link Stmt#declareVariable(String, TypeLiteral, Object)}. - * - * @param name - * The variable name - * @param type - * The variable reference type - * @return A newly created variable that is not (yet) referencable. - */ - public static Variable create(final String name, final TypeLiteral type, final Object initialization) { - return new Variable(name, MetaClassFactory.get(type), initialization); - } - - /** - * Creates a variable, but does not assign it to a scope. If you are trying to - * declare a variable, see {@link Stmt#declareVariable(String, MetaClass, Object)}. - * - * @param name - * The variable name - * @param type - * The variable reference type - * @return A newly created variable that is not (yet) referencable. - */ - public static Variable create(final String name, final MetaClass type, final Object initialization) { - return new Variable(name, type, initialization); - } - - public static VariableReference get(final String name) { - return new VariableReference() { - private MetaClass type; - - @Override - public String getName() { - return name; - } - - @Override - public Statement getValue() { - return new Statement() { - @Override - public String generate(Context context) { - return name; - } - - @Override - public MetaClass getType() { - return type; - } - }; - } - - @Override - public String generate(Context context) { - type = context.getVariable(name).getType(); - return name; - } - - @Override - public MetaClass getType() { - return type; - } - - @Override - public String toString() { - return name; - } - }; - } - - public VariableReference getReference() { - return new VariableReference() { - @Override - public String getName() { - return name; - } - - @Override - public MetaClass getType() { - return type; - } - - @Override - public Statement getValue() { - return value; - } - - @Override - public String toString() { - return name; - } - }; - } - - public String getName() { - return name; - } - - @Override - public MetaClass getType() { - return type; - } - - public Statement getValue() { - return value; - } - - public boolean isFinal() { - return isFinal; - } - - private String hashString; - - private String hashString() { - if (hashString == null) { - hashString = Variable.class.getName() + ":" + name + ":" + type.getFullyQualifiedName(); - } - return hashString; - } - - @Override - public boolean equals(final Object o) { - return o instanceof Variable - && hashString().equals(Variable.class.getName() + ":" + name + ":" + ((Variable) o).type.getFullyQualifiedName()); - } - - @Override - public int hashCode() { - return hashString().hashCode(); - } - - @Override - public String toString() { - return "Variable [name=" + name + ", type=" + type + "]"; - } - - String generatedCache; - - @Override - public String generate(final Context context) { - if (generatedCache != null) return generatedCache; - - if (initialization != null) { - this.type = (type == null) ? inferType(context, initialization) : type; - this.value = GenUtil.convert(context, initialization, type); - } - - return generatedCache = new DeclareAssignmentBuilder(isFinal, getReference(), value).generate(context); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/VariableReference.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/VariableReference.java deleted file mode 100644 index 3f737371bbb..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/VariableReference.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -/** - * {@link Statement} thats represents a reference to a {@link Variable}. - * - * @author Mike Brock - * @author Christian Sadilek - */ -public abstract class VariableReference extends AbstractStatement { - public abstract String getName(); - public abstract Statement getValue(); - - protected Statement[] indexes; - - @Override - public String generate(final Context context) { - return getName(); - } - - public Statement[] getIndexes() { - return indexes; - } - - public void setIndexes(final Statement[] indexes) { - this.indexes = indexes; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/WeaveType.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/WeaveType.java deleted file mode 100644 index 3b59e61a587..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/WeaveType.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 org.jboss.errai.codegen; - -/** - * @author Mike Brock - */ -public enum WeaveType { - BeforeInvoke, AfterInvoke, AroundInvoke -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/AnonymousClassStructureBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/AnonymousClassStructureBuilder.java deleted file mode 100644 index 049b8ce743f..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/AnonymousClassStructureBuilder.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import org.jboss.errai.codegen.Parameter; -import org.jboss.errai.codegen.builder.impl.ObjectBuilder; - -/** - * @author Mike Brock - */ -public interface AnonymousClassStructureBuilder - extends ClassStructureBuilder, Finishable { - - public BlockBuilder initialize(); - - public BlockBuilder publicOverridesMethod(String name, Parameter... args); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ArrayBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ArrayBuilder.java deleted file mode 100644 index 71d8b853a8d..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ArrayBuilder.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Christian Sadilek - */ -public interface ArrayBuilder extends Statement, Builder { - - public ArrayInitializationBuilder newArray(MetaClass componentType, Object... dimensions); - - public ArrayInitializationBuilder newArray(Class componentType, Object... dimensions); - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ArrayInitializationBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ArrayInitializationBuilder.java deleted file mode 100644 index f2efa3ddeae..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ArrayInitializationBuilder.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.builder.impl.AbstractStatementBuilder; - -/** - * @author Christian Sadilek - */ -public interface ArrayInitializationBuilder extends Statement, Builder { - public AbstractStatementBuilder initialize(Object... values); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/BlockBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/BlockBuilder.java deleted file mode 100644 index 02fff3a2ad7..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/BlockBuilder.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import java.util.Collection; -import java.util.List; - -import org.jboss.errai.codegen.InnerClass; -import org.jboss.errai.codegen.Statement; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public interface BlockBuilder extends Finishable, Iterable { - public void insertBefore(Statement stmt); - public void insertBefore(InnerClass innerClass); - - public BlockBuilder append(Statement stmt); - public BlockBuilder appendAll(Collection stmt); - - public BlockBuilder append(InnerClass innerClass); - - - /** - * Alias for {@link #append(org.jboss.errai.codegen.Statement)} - * @param stmt the statement to add to the block - * @return - */ - public BlockBuilder _(Statement stmt); - - /** - * Alias for {@link #append(org.jboss.errai.codegen.InnerClass)} )} - * @param innerClass the statement to add to the block - * @return - */ - public BlockBuilder _(InnerClass innerClass); - - /** - * Return a list of statements from the specified statement (inclusive), and remove all of the returned statements - * from the underlying builder. - * - * @param statement the statement to split from. - * @return a list of statements from the specified statement - */ - public List splitFrom(Statement statement); - - /** - * Show the last statement in the block. - * - * @return the last statement in the block. - */ - public Statement peek(); - - public void clear(); -} - diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/BuildCallback.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/BuildCallback.java deleted file mode 100644 index 1c9e9234266..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/BuildCallback.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; - -/** - * @author Mike Brock - */ -public interface BuildCallback { - public T callback(Statement statement); - public Context getParentContext(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/Builder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/Builder.java deleted file mode 100644 index 9de82d4cfa9..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/Builder.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -/** - * @author Mike Brock - */ -public interface Builder { - /** - * Validates the statement and generates the String representation. - * - * @return Java String representation - */ - public String toJavaString(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/CaseBlockBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/CaseBlockBuilder.java deleted file mode 100644 index e7964a32ef4..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/CaseBlockBuilder.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.literal.ByteValue; -import org.jboss.errai.codegen.literal.CharValue; -import org.jboss.errai.codegen.literal.IntValue; -import org.jboss.errai.codegen.literal.LiteralValue; -import org.jboss.errai.codegen.literal.ShortValue; - -/** - * @author Christian Sadilek - */ -public interface CaseBlockBuilder extends Statement, Builder { - BlockBuilder case_(int value); - BlockBuilder case_(byte value); - BlockBuilder case_(short value); - BlockBuilder case_(char value); - BlockBuilder case_(String value); - BlockBuilder case_(Enum value); - - BlockBuilder case_(IntValue value); - BlockBuilder case_(ByteValue value); - BlockBuilder case_(ShortValue value); - BlockBuilder case_(CharValue value); - BlockBuilder case_(LiteralValue> value); - - BlockBuilder default_(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/CatchBlockBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/CatchBlockBuilder.java deleted file mode 100644 index af65f4c5cd5..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/CatchBlockBuilder.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Christian Sadilek - */ -public interface CatchBlockBuilder extends Statement, Builder { - BlockBuilder catch_(Class exceptionType, String variableName); - BlockBuilder catch_(MetaClass exceptionType, String variableName); - - BlockBuilder finally_(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClassConstructorBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClassConstructorBuilder.java deleted file mode 100644 index 0ffbb0c1157..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClassConstructorBuilder.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import org.jboss.errai.codegen.Parameter; -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public interface ClassConstructorBuilder extends Builder { - public ConstructorBlockBuilder publicConstructor(); - public ConstructorBlockBuilder publicConstructor(MetaClass... parms); - public ConstructorBlockBuilder publicConstructor(Class... parms); - public ConstructorBlockBuilder publicConstructor(Parameter... parms); - - public ConstructorBlockBuilder privateConstructor(); - public ConstructorBlockBuilder privateConstructor(MetaClass... parms); - public ConstructorBlockBuilder privateConstructor(Class... parms); - public ConstructorBlockBuilder privateConstructor(Parameter... parms); - - public ConstructorBlockBuilder protectedConstructor(); - public ConstructorBlockBuilder protectedConstructor(MetaClass... parms); - public ConstructorBlockBuilder protectedConstructor(Class... parms); - public ConstructorBlockBuilder protectedConstructor(Parameter... parms); - - public ConstructorBlockBuilder packageConstructor(); - public ConstructorBlockBuilder packageConstructor(MetaClass... parms); - public ConstructorBlockBuilder packageConstructor(Class... parms); - public ConstructorBlockBuilder packageConstructor(Parameter... parms); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClassDefinitionBuilderAbstractOption.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClassDefinitionBuilderAbstractOption.java deleted file mode 100644 index 12b2f7a31a2..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClassDefinitionBuilderAbstractOption.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -/** - * @author Christian Sadilek - */ -public interface ClassDefinitionBuilderAbstractOption> - extends ClassDefinitionBuilderInterfaces { - - public ClassDefinitionBuilderInterfaces abstractClass(); - - public ClassDefinitionBuilderInterfaces interfaceDefinition(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClassDefinitionBuilderCommentOption.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClassDefinitionBuilderCommentOption.java deleted file mode 100644 index 061bc83aac4..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClassDefinitionBuilderCommentOption.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -/** - * @author Johannes Barop - */ -public interface ClassDefinitionBuilderCommentOption> extends - ClassDefinitionBuilderScope { - public ClassDefinitionBuilderScope classComment(String comment); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClassDefinitionBuilderInterfaces.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClassDefinitionBuilderInterfaces.java deleted file mode 100644 index 43de5525275..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClassDefinitionBuilderInterfaces.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Mike Brock - */ -public interface ClassDefinitionBuilderInterfaces> { - public ClassDefinitionBuilderInterfaces implementsInterface(MetaClass clazz); - - public ClassDefinitionBuilderInterfaces implementsInterface(Class clazz); - - public ClassStructureBuilder body(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClassDefinitionBuilderScope.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClassDefinitionBuilderScope.java deleted file mode 100644 index 4b656a67dd3..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClassDefinitionBuilderScope.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -/** - * @author Mike Brock - */ -public interface ClassDefinitionBuilderScope> { - public ClassDefinitionStaticOption publicScope(); - - public ClassDefinitionStaticOption privateScope(); - - public ClassDefinitionStaticOption protectedScope(); - - public ClassDefinitionStaticOption packageScope(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClassDefinitionStaticOption.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClassDefinitionStaticOption.java deleted file mode 100644 index fd5b5438d7d..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClassDefinitionStaticOption.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -/** - * @author Mike Brock - */ -public interface ClassDefinitionStaticOption> - extends ClassDefinitionBuilderAbstractOption { - - public ClassDefinitionBuilderAbstractOption staticClass(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClassFieldBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClassFieldBuilder.java deleted file mode 100644 index c2d807e067f..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClassFieldBuilder.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public interface ClassFieldBuilder> extends Builder { - public FieldBuildStart publicField(String name, MetaClass type); - public FieldBuildStart publicField(String name, Class type); - - public FieldBuildStart privateField(String name, MetaClass type); - public FieldBuildStart privateField(String name, Class type); - - public FieldBuildStart protectedField(String name, MetaClass type); - public FieldBuildStart protectedField(String name, Class type); - - public FieldBuildStart packageField(String name, MetaClass type); - public FieldBuildStart packageField(String name, Class type); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClassMethodBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClassMethodBuilder.java deleted file mode 100644 index 687354fc0d4..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClassMethodBuilder.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import org.jboss.errai.codegen.Parameter; -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public interface ClassMethodBuilder> extends ClassConstructorBuilder, - ClassFieldBuilder, Builder { - - public MethodCommentBuilder publicMethod(MetaClass returnType, String name); - - public MethodCommentBuilder publicMethod(Class returnType, String name); - - public MethodCommentBuilder publicMethod(MetaClass returnType, String name, MetaClass... parms); - - public MethodCommentBuilder publicMethod(Class returnType, String name, Class... parms); - - public MethodCommentBuilder publicMethod(MetaClass returnType, String name, Parameter... parms); - - public MethodCommentBuilder publicMethod(Class returnType, String name, Parameter... parms); - - public MethodCommentBuilder privateMethod(MetaClass returnType, String name); - - public MethodCommentBuilder privateMethod(Class returnType, String name); - - public MethodCommentBuilder privateMethod(MetaClass returnType, String name, MetaClass... parms); - - public MethodCommentBuilder privateMethod(Class returnType, String name, Class... parms); - - public MethodCommentBuilder privateMethod(MetaClass returnType, String name, Parameter... parms); - - public MethodCommentBuilder privateMethod(Class returnType, String name, Parameter... parms); - - public MethodCommentBuilder protectedMethod(MetaClass returnType, String name); - - public MethodCommentBuilder protectedMethod(Class returnType, String name); - - public MethodCommentBuilder protectedMethod(MetaClass returnType, String name, - MetaClass... parms); - - public MethodCommentBuilder protectedMethod(Class returnType, String name, Class... parms); - - public MethodCommentBuilder protectedMethod(MetaClass returnType, String name, - Parameter... parms); - - public MethodCommentBuilder protectedMethod(Class returnType, String name, Parameter... parms); - - public MethodCommentBuilder packageMethod(MetaClass returnType, String name); - - public MethodCommentBuilder packageMethod(Class returnType, String name); - - public MethodCommentBuilder packageMethod(MetaClass returnType, String name, MetaClass... parms); - - public MethodCommentBuilder packageMethod(Class returnType, String name, Class... parms); - - public MethodCommentBuilder packageMethod(MetaClass returnType, String name, Parameter... parms); - - public MethodCommentBuilder packageMethod(Class returnType, String name, Parameter... parms); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClassStructureBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClassStructureBuilder.java deleted file mode 100644 index 6059e8d97dc..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClassStructureBuilder.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import org.jboss.errai.codegen.InnerClass; -import org.jboss.errai.codegen.meta.impl.build.BuildMetaClass; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public interface ClassStructureBuilder> extends ClassMethodBuilder, - ClassConstructorBuilder, ClassFieldBuilder, Builder { - - public ClassStructureBuilder declaresInnerClass(InnerClass ic); - - /** - * The mutable class definition which is being constructed by this builder. - * - * @return an instance of {@link BuildMetaClass} - */ - public BuildMetaClass getClassDefinition(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClassStructureBuilderAbstractMethodOption.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClassStructureBuilderAbstractMethodOption.java deleted file mode 100644 index 6ddb0b3bd65..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClassStructureBuilderAbstractMethodOption.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import org.jboss.errai.codegen.Parameter; -import org.jboss.errai.codegen.builder.impl.MethodBuilderAbstractOption; -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Christian Sadilek - */ -public interface ClassStructureBuilderAbstractMethodOption extends - ClassStructureBuilder, - ClassConstructorBuilder, - ClassFieldBuilder, - Builder { - - public MethodBuilderAbstractOption publicAbstractMethod( - MetaClass returnType, String name); - - public MethodBuilderAbstractOption publicAbstractMethod( - Class returnType, String name); - - public MethodBuilderAbstractOption publicAbstractMethod( - MetaClass returnType, String name, MetaClass... parms); - - public MethodBuilderAbstractOption publicAbstractMethod( - Class returnType, String name, Class... parms); - - public MethodBuilderAbstractOption publicAbstractMethod( - MetaClass returnType, String name, Parameter... parms); - - public MethodBuilderAbstractOption publicAbstractMethod( - Class returnType, String name, Parameter... parms); - - public MethodBuilderAbstractOption protectedAbstractMethod( - MetaClass returnType, String name); - - public MethodBuilderAbstractOption protectedAbstractMethod( - Class returnType, String name); - - public MethodBuilderAbstractOption protectedAbstractMethod( - MetaClass returnType, String name, MetaClass... parms); - - public MethodBuilderAbstractOption protectedAbstractMethod( - Class returnType, String name, Class... parms); - - public MethodBuilderAbstractOption protectedAbstractMethod( - MetaClass returnType, String name, Parameter... parms); - - public MethodBuilderAbstractOption protectedAbstractMethod( - Class returnType, String name, Parameter... parms); - - public MethodBuilderAbstractOption packageAbstractMethod( - MetaClass returnType, String name); - - public MethodBuilderAbstractOption packageAbstractMethod( - Class returnType, String name); - - public MethodBuilderAbstractOption packageAbstractMethod( - MetaClass returnType, String name, MetaClass... parms); - - public MethodBuilderAbstractOption packageAbstractMethod( - Class returnType, String name, Class... parms); - - public MethodBuilderAbstractOption packageAbstractMethod( - MetaClass returnType, String name, Parameter... parms); - - public MethodBuilderAbstractOption packageAbstractMethod( - Class returnType, String name, Parameter... parms); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClosedBlock.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClosedBlock.java deleted file mode 100644 index 65ad4a138fb..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ClosedBlock.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -/** - * Marker interface to indicate to the generator if the statement is a block statement. Used mainly to ensure - * proper placement of statement terminating semi-colons. - * - * @author Mike Brock - */ -public interface ClosedBlock { -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ConstructorBlockBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ConstructorBlockBuilder.java deleted file mode 100644 index 4769b3401c3..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ConstructorBlockBuilder.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -/** - * @author Mike Brock - */ -public interface ConstructorBlockBuilder extends BlockBuilder { - public BlockBuilder callSuper(); - public BlockBuilder callSuper(Object... parameters); - - public BlockBuilder callThis(Object... parameters); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ContextualIfBlockBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ContextualIfBlockBuilder.java deleted file mode 100644 index db14299453e..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ContextualIfBlockBuilder.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import org.jboss.errai.codegen.BooleanOperator; -import org.jboss.errai.codegen.Statement; - -/** - * @author Christian Sadilek - */ -public interface ContextualIfBlockBuilder extends Statement, Builder { - BlockBuilder if_(); - BlockBuilder if_(BooleanOperator op, Statement rhs); - BlockBuilder if_(BooleanOperator op, Object rhs); - - BlockBuilder ifNot(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ContextualLoopBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ContextualLoopBuilder.java deleted file mode 100644 index 926204cad2f..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ContextualLoopBuilder.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import org.jboss.errai.codegen.BooleanExpression; -import org.jboss.errai.codegen.BooleanOperator; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Christian Sadilek - */ -public interface ContextualLoopBuilder extends Statement, Builder { - public BlockBuilder foreach(String loopVarName); - public BlockBuilder foreach(String loopVarName, Class loopVarType); - public BlockBuilder foreach(String loopVarName, MetaClass loopVarType); - - public BlockBuilder foreachIfNotNull(String loopVarName); - public BlockBuilder foreachIfNotNull(String loopVarName, Class loopVarType); - public BlockBuilder foreachIfNotNull(String loopVarName, MetaClass loopVarType); - - public BlockBuilder for_(Statement initializer, BooleanExpression condition); - public BlockBuilder for_(Statement initializer, BooleanExpression condition, Statement countingExpression); - - public BlockBuilder do_(); - - public BlockBuilder while_(); - public BlockBuilder while_(BooleanOperator op, Statement rhs); - public BlockBuilder while_(BooleanOperator op, Object rhs); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ContextualStatementBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ContextualStatementBuilder.java deleted file mode 100644 index 01ee08e6ead..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ContextualStatementBuilder.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.meta.MetaField; -import org.jboss.errai.codegen.meta.MetaMethod; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public interface ContextualStatementBuilder extends ContextualLoopBuilder, ContextualIfBlockBuilder, - ContextualSwitchBlockBuilder { - - public ContextualStatementBuilder invoke(MetaMethod method, Object... parameters); - - public ContextualStatementBuilder invoke(String methodName, Object... parameters); - - public VariableReferenceContextualStatementBuilder loadField(MetaField field); - - public VariableReferenceContextualStatementBuilder loadField(String fieldName); - - public Statement returnValue(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ContextualSwitchBlockBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ContextualSwitchBlockBuilder.java deleted file mode 100644 index d3dfa9ce16c..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ContextualSwitchBlockBuilder.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import org.jboss.errai.codegen.Statement; - -/** - * @author Christian Sadilek - */ -public interface ContextualSwitchBlockBuilder extends Statement, Builder { - public CaseBlockBuilder switch_(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/DefaultClassStructureBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/DefaultClassStructureBuilder.java deleted file mode 100644 index 311f3ea0b97..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/DefaultClassStructureBuilder.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - - -/** - * @author Christian Sadilek - */ -public interface DefaultClassStructureBuilder extends - ClassStructureBuilder, - ClassConstructorBuilder, - ClassFieldBuilder, - Builder { - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ElseBlockBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ElseBlockBuilder.java deleted file mode 100644 index afd19f55cd6..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/ElseBlockBuilder.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import org.jboss.errai.codegen.BooleanOperator; -import org.jboss.errai.codegen.Statement; - -/** - * @author Christian Sadilek - */ -public interface ElseBlockBuilder extends Statement, Builder, ClosedBlock { - BlockBuilder else_(); - - BlockBuilder elseif_(Statement lhs); - - BlockBuilder elseif_(Statement lhs, BooleanOperator op, Statement rhs); - - BlockBuilder elseif_(Statement lhs, BooleanOperator op, Object rhs); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/FieldBuildInitializer.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/FieldBuildInitializer.java deleted file mode 100644 index 98310d89c84..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/FieldBuildInitializer.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import java.lang.annotation.Annotation; - -import org.jboss.errai.codegen.Statement; - -/** - * @author Mike Brock - */ -public interface FieldBuildInitializer extends Finishable { - public FieldBuildInitializer annotatedWith(Annotation... annotation); - - public Finishable initializesWith(Statement statement); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/FieldBuildName.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/FieldBuildName.java deleted file mode 100644 index 74ddfa7de74..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/FieldBuildName.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -/** - * @author Mike Brock - */ -public interface FieldBuildName { - public FieldBuildInitializer named(String name); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/FieldBuildStart.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/FieldBuildStart.java deleted file mode 100644 index 1aa541fc67d..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/FieldBuildStart.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import org.jboss.errai.codegen.Modifier; - -/** - * @author Mike Brock - */ -public interface FieldBuildStart extends FieldBuildInitializer{ - public FieldBuildInitializer modifiers(Modifier... modifiers); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/FieldBuildType.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/FieldBuildType.java deleted file mode 100644 index 148b64cf670..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/FieldBuildType.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Mike Brock - */ -public interface FieldBuildType { - public FieldBuildName typeOf(Class type); - - public FieldBuildName typeOf(MetaClass type); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/Finishable.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/Finishable.java deleted file mode 100644 index 157b63e896e..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/Finishable.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -/** - * @author Mike Brock - */ -public interface Finishable { - public T finish(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/IfBlockBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/IfBlockBuilder.java deleted file mode 100644 index 97d85510107..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/IfBlockBuilder.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import org.jboss.errai.codegen.BooleanExpression; -import org.jboss.errai.codegen.Statement; - -/** - * @author Christian Sadilek - */ -public interface IfBlockBuilder extends Statement, Builder, ClosedBlock { - public BlockBuilder if_(BooleanExpression condition); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/LoopBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/LoopBuilder.java deleted file mode 100644 index a03457ca89b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/LoopBuilder.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import org.jboss.errai.codegen.BooleanExpression; -import org.jboss.errai.codegen.Statement; - -/** - * @author Christian Sadilek - */ -public interface LoopBuilder extends Statement, Builder, ClosedBlock { - public BlockBuilder do_(); - - public BlockBuilder while_(BooleanExpression condition); - - public BlockBuilder for_(BooleanExpression condition); - - public BlockBuilder for_(Statement initializer, BooleanExpression condition); - - public BlockBuilder for_(Statement initializer, BooleanExpression condition, - Statement countingExpression); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/MethodBlockBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/MethodBlockBuilder.java deleted file mode 100644 index e886453ba9f..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/MethodBlockBuilder.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import java.lang.annotation.Annotation; - -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Mike Brock - */ -public interface MethodBlockBuilder extends BlockBuilder, - MethodBlockModifiers, T>, - MethodBlockParameters { - - public MethodBlockBuilder annotatedWith(Annotation... annotations); - - public MethodBlockBuilder throws_(Class... exceptionTypes); - - public MethodBlockBuilder throws_(MetaClass... exceptions); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/MethodBlockModifiers.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/MethodBlockModifiers.java deleted file mode 100644 index 8a4fec2bb45..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/MethodBlockModifiers.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import org.jboss.errai.codegen.Modifier; - -/** - * @author Mike Brock - */ -public interface MethodBlockModifiers { - public B modifiers(Modifier... modifiers); - - public BlockBuilder body(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/MethodBlockParameters.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/MethodBlockParameters.java deleted file mode 100644 index bf571614155..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/MethodBlockParameters.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import org.jboss.errai.codegen.DefParameters; -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Mike Brock - */ -public interface MethodBlockParameters { - public MethodBlockBuilder parameters(DefParameters parms); - - public MethodBlockBuilder parameters(Class... parms); - - public MethodBlockBuilder parameters(MetaClass... parms); - - public MethodBlockBuilder parameters(Object... parms); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/MethodBuildCallback.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/MethodBuildCallback.java deleted file mode 100644 index 6b722e66258..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/MethodBuildCallback.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import java.lang.annotation.Annotation; -import java.util.List; - -import org.jboss.errai.codegen.BlockStatement; -import org.jboss.errai.codegen.DefModifiers; -import org.jboss.errai.codegen.DefParameters; -import org.jboss.errai.codegen.ThrowsDeclaration; - -/** - * @author Christian Sadilek - */ -public interface MethodBuildCallback { - public T callback(BlockStatement statement, DefParameters parms, DefModifiers modifiers, - ThrowsDeclaration throwsDeclaration, List annotations, String comment); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/MethodCommentBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/MethodCommentBuilder.java deleted file mode 100644 index a900f8b7d0c..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/MethodCommentBuilder.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -/** - * @author Mike Brock - */ -public interface MethodCommentBuilder extends MethodBlockBuilder { - public MethodBlockBuilder methodComment(String comment); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/StatementBegin.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/StatementBegin.java deleted file mode 100644 index fdcd25e62ec..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/StatementBegin.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import javax.enterprise.util.TypeLiteral; - -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.builder.impl.ObjectBuilder; -import org.jboss.errai.codegen.builder.impl.StatementBuilder; -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public interface StatementBegin extends ArrayBuilder, LoopBuilder, IfBlockBuilder, SwitchBlockBuilder, TryBlockBuilder { - public VariableDeclarationStart declareVariable(Class type); - public VariableDeclarationStart declareVariable(MetaClass type); - - public StatementBuilder declareVariable(String name, Class type); - public StatementBuilder declareVariable(String name, TypeLiteral type); - public StatementBuilder declareVariable(String name, Object initialization); - public StatementBuilder declareVariable(String name, MetaClass type, Object initialization); - public StatementBuilder declareVariable(String name, Class type, Object initialization); - public StatementBuilder declareVariable(String name, TypeLiteral type, Object initialization); - - public StatementBuilder declareFinalVariable(String name, Class type); - public StatementBuilder declareFinalVariable(String name, TypeLiteral type); - public StatementBuilder declareFinalVariable(String name, MetaClass type, Object initialization); - public StatementBuilder declareFinalVariable(String name, Class type, Object initialization); - public StatementBuilder declareFinalVariable(String name, TypeLiteral type, Object initialization); - - public VariableReferenceContextualStatementBuilder loadVariable(String name, Object... indexes); - public VariableReferenceContextualStatementBuilder loadClassMember(String name, Object... indexes); - public ContextualStatementBuilder loadLiteral(Object o); - public ContextualStatementBuilder load(Object o); - public ContextualStatementBuilder loadClassReference(Object o); - - public ContextualStatementBuilder invokeStatic(MetaClass clazz, String methodName, Object... parameters); - public ContextualStatementBuilder invokeStatic(Class clazz, String methodName, Object... parameters); - - public ContextualStatementBuilder loadStatic(Class clazz, String fieldName); - public ContextualStatementBuilder loadStatic(MetaClass clazz, String fieldName); - - public ContextualStatementBuilder nestedCall(Statement statement); - - public ContextualStatementBuilder castTo(Class type, Statement statement); - public ContextualStatementBuilder castTo(MetaClass type, Statement statement); - - public ObjectBuilder newObject(Class type); - public ObjectBuilder newObject(MetaClass type); - public ObjectBuilder newObject(TypeLiteral type); - - public Statement newObject(Class type, Object... parameters); - public Statement newObject(MetaClass type, Object... parameters); - public Statement newObject(TypeLiteral type, Object... parameters); - - public StatementEnd throw_(Class throwableType, Object... parameters); - public StatementEnd throw_(String exceptionVarName); - - public StatementEnd label(String label); - - public StatementEnd break_(); - public StatementEnd break_(String label); - - public StatementEnd continue_(); - public StatementEnd continue_(String label); - - public StatementEnd returnVoid(); - - public Statement codeComment(String comment); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/StatementEnd.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/StatementEnd.java deleted file mode 100644 index 66618774308..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/StatementEnd.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import org.jboss.errai.codegen.Statement; - -/** - * @author Christian Sadilek - */ -public interface StatementEnd extends Statement, Builder { - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/SwitchBlockBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/SwitchBlockBuilder.java deleted file mode 100644 index b7713beafaa..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/SwitchBlockBuilder.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import org.jboss.errai.codegen.Statement; - -/** - * @author Christian Sadilek - */ -public interface SwitchBlockBuilder extends Statement, Builder, ClosedBlock { - public CaseBlockBuilder switch_(Statement statement); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/TryBlockBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/TryBlockBuilder.java deleted file mode 100644 index fb16da32bbe..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/TryBlockBuilder.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import org.jboss.errai.codegen.Statement; - -/** - * @author Christian Sadilek - */ -public interface TryBlockBuilder extends Statement, Builder, ClosedBlock { - public BlockBuilder try_(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/VariableDeclarationInitializer.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/VariableDeclarationInitializer.java deleted file mode 100644 index dad4111d919..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/VariableDeclarationInitializer.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import org.jboss.errai.codegen.Statement; - -/** - * @author Mike Brock - */ -public interface VariableDeclarationInitializer { - public T initializeWith(Object initialization); - - public T initializeWith(Statement initialization); - - public T finish(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/VariableDeclarationNamed.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/VariableDeclarationNamed.java deleted file mode 100644 index c9f9e75827f..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/VariableDeclarationNamed.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -/** - * @author Mike Brock - */ -public interface VariableDeclarationNamed extends VariableDeclarationInitializer { - public VariableDeclarationInitializer named(String name); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/VariableDeclarationStart.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/VariableDeclarationStart.java deleted file mode 100644 index 25c9f06b6ca..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/VariableDeclarationStart.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -/** - * @author Mike Brock - */ -public interface VariableDeclarationStart extends VariableDeclarationNamed { - public VariableDeclarationNamed asFinal(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/VariableReferenceContextualStatementBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/VariableReferenceContextualStatementBuilder.java deleted file mode 100644 index e017d113c73..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/VariableReferenceContextualStatementBuilder.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import org.jboss.errai.codegen.AssignmentOperator; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public interface VariableReferenceContextualStatementBuilder extends ContextualStatementBuilder { - public StatementEnd assignValue(Object value); - public StatementEnd assignValue(AssignmentOperator operator, Object value); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/WhileBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/WhileBuilder.java deleted file mode 100644 index 3a184a4a29c..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/WhileBuilder.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder; - -import org.jboss.errai.codegen.BooleanExpression; -import org.jboss.errai.codegen.BooleanOperator; -import org.jboss.errai.codegen.Statement; - -/** - * @author Christian Sadilek - */ -public interface WhileBuilder { - public StatementEnd while_(BooleanExpression stmt); - public StatementEnd while_(); - public StatementEnd while_(BooleanOperator op, Statement rhs); - public StatementEnd while_(BooleanOperator op, Object rhs); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/AbstractCallElement.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/AbstractCallElement.java deleted file mode 100644 index 43470abc50b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/AbstractCallElement.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.callstack; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.exception.GenerationException; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.util.GenUtil; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public abstract class AbstractCallElement implements CallElement { - protected CallElement next; - protected MetaClass resultType = null; - - private final static boolean blameDetailsEnabled = Boolean.getBoolean("errai.codegen.details"); - private final RuntimeException blame = (blameDetailsEnabled) ? new RuntimeException("Problem was caused by this call") : null; - - public void nextOrReturn(CallWriter writer, Context ctx, Statement statement) { - try { - if (statement != null) { - if (!writer.getCallString().isEmpty()) { - writer.append("."); - } - writer.append(statement.generate(ctx)); - resultType = statement.getType(); - } - - if (next != null) { - getNext().handleCall(writer, ctx, statement); - } - } - catch (final GenerationException e) { - blameAndRethrow(e); - } - } - - @Override - public CallElement setNext(CallElement next) { - return this.next = next; - } - - @Override - public CallElement getNext() { - return next; - } - - public static void append(CallElement start, CallElement last) { - CallElement el = start; - while (el.getNext() != null) - el = el.getNext(); - - el.setNext(last); - } - - @Override - public MetaClass getResultType() { - return resultType; - } - - @Override - public String toString() { - return "[CallElement<" + next + ">]"; - } - - protected void blameAndRethrow(GenerationException e) { - if (!blameDetailsEnabled) { - final RuntimeException blamePlaceHolder = new RuntimeException( - "Problem during Errai code generation. Please set system property -Derrai.codegen.details=true for more details."); - blamePlaceHolder.initCause(e); - throw blamePlaceHolder; - } - - if (e.getCause() == null) { - GenUtil.rewriteBlameStackTrace(blame); - e.initCause(blame); - } - throw e; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/AssignVariable.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/AssignVariable.java deleted file mode 100644 index a44cd32f550..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/AssignVariable.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.callstack; - -import org.jboss.errai.codegen.AssignmentOperator; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.VariableReference; -import org.jboss.errai.codegen.builder.impl.AssignmentBuilder; -import org.jboss.errai.codegen.exception.GenerationException; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.util.GenUtil; - -/** - * {@link CallElement} to assign a value to a variable. - * - * @author Christian Sadilek - */ -public class AssignVariable extends AbstractCallElement { - private final AssignmentOperator operator; - private final Object value; - - public AssignVariable(final AssignmentOperator operator, final Object value) { - this.operator = operator; - this.value = value; - } - - @Override - public void handleCall(final CallWriter writer, final Context context, final Statement statement) { - writer.reset(); - - final Statement stmt = new AssignmentBuilder(false, operator, (VariableReference) statement, GenUtil.generate(context, - value)); - - final Statement wrapperStmt; - - try { - if (next == null) { - wrapperStmt = new Statement() { - @Override - public String generate(final Context context) { - return stmt.generate(context).concat(";"); - } - - @Override - public MetaClass getType() { - return stmt.getType(); - } - }; - nextOrReturn(writer, context, wrapperStmt); - } - else { - nextOrReturn(writer, context, stmt); - } - } - catch (GenerationException e) { - blameAndRethrow(e); - } - } - - @Override - public String toString() { - return "[[Assignment<" + operator.getCanonicalString() + ":" + value + ">]" + next + "]"; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/BranchCallElement.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/BranchCallElement.java deleted file mode 100644 index 2656c6b0f68..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/BranchCallElement.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.callstack; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.control.branch.AbstractBranchStatement; - -/** - * @author Christian Sadilek - */ -public class BranchCallElement extends AbstractCallElement { - private final AbstractBranchStatement branchStatement; - - public BranchCallElement(final AbstractBranchStatement branchStatement) { - this.branchStatement = branchStatement; - } - - @Override - public void handleCall(final CallWriter writer, final Context context, final Statement statement) { - writer.append(branchStatement.generate(context)); - } - - @Override - public String toString() { - return "[[BranchStatement<" + branchStatement + ">]" + next + "]"; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/CallElement.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/CallElement.java deleted file mode 100644 index 315df01402a..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/CallElement.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.callstack; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public interface CallElement { - public void handleCall(CallWriter writer, Context context, Statement statement); - - public CallElement setNext(CallElement element); - - public CallElement getNext(); - - public MetaClass getResultType(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/CallWriter.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/CallWriter.java deleted file mode 100644 index 671716110eb..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/CallWriter.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.callstack; - -import java.util.HashMap; -import java.util.Map; - -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Mike Brock - */ -public class CallWriter { - private StringBuilder buffer; - private final Map typeParmCapture = new HashMap(); - - public CallWriter() { - reset(); - } - - public CallWriter prepend(final String str) { - buffer.insert(0, str); - return this; - } - - public CallWriter append(final String str) { - buffer.append(str); - return this; - } - - public void reset() { - buffer = new StringBuilder(128); - } - - public String getCallString() { - return buffer.toString(); - } - - public void recordTypeParm(final String var, final MetaClass type) { - this.typeParmCapture.put(var, type); - } - - public MetaClass getTypeParm(final String var) { - return typeParmCapture.get(var); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/ConditionalBlockCallElement.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/ConditionalBlockCallElement.java deleted file mode 100644 index 2f5c42352e2..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/ConditionalBlockCallElement.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.callstack; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.control.AbstractConditionalBlock; -import org.jboss.errai.codegen.exception.GenerationException; - -/** - * A {@link CallElement} for conditional blocks. It can only be the last - * element in a chain of calls. - * - * @author Christian Sadilek - */ -public class ConditionalBlockCallElement extends AbstractCallElement { - private final AbstractConditionalBlock conditionalBlock; - - public ConditionalBlockCallElement(final AbstractConditionalBlock conditionalBlock) { - this.conditionalBlock = conditionalBlock; - } - - @Override - public void handleCall(final CallWriter writer, final Context context, final Statement lhs) { - try { - if (lhs != null) { - // The LHS value is on the current callstack. So we grab the value from there at generation time. - conditionalBlock.getCondition().setLhs(lhs); - conditionalBlock.getCondition().setLhsExpr(writer.getCallString()); - } - writer.reset(); - writer.append(conditionalBlock.generate(Context.create(context))); - } - catch(GenerationException e) { - blameAndRethrow(e); - } - } - - @Override - public String toString() { - return "[[Conditional<" + conditionalBlock + ">]" + next + "]"; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/DeclareVariable.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/DeclareVariable.java deleted file mode 100644 index 5fec1fee069..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/DeclareVariable.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.callstack; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.Variable; - -/** - * @author Mike Brock - */ -public class DeclareVariable extends AbstractCallElement { - private final Variable variable; - - public DeclareVariable(final Variable variable) { - this.variable = variable; - } - - @Override - public void handleCall(final CallWriter writer, final Context context, final Statement statement) { - writer.reset(); - context.addVariable(variable); - writer.append(variable.generate(context)); - if (next == null) { - writer.append(";"); - } - - nextOrReturn(writer, context, null); - } - - public String toString() { - return "[[DeclareVariable<" + variable + ">]" + next + "]"; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/DeferredCallElement.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/DeferredCallElement.java deleted file mode 100644 index b3148bfe62b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/DeferredCallElement.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.callstack; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.exception.GenerationException; - -/** - * An element for deferring and offloading validation and generation work for building the - * call stack. - * - * @author Mike Brock - */ -public class DeferredCallElement extends AbstractCallElement { - private final DeferredCallback callback; - - public DeferredCallElement(final DeferredCallback callback) { - this.callback = callback; - } - - @Override - public void handleCall(final CallWriter writer, - final Context context, - final Statement statement) { - - try { - callback.doDeferred(writer, context, statement); - - if (next != null) { - writer.append("."); - getNext().handleCall(writer, context, statement); - } - } - catch (GenerationException e) { - blameAndRethrow(e); - } - } - - @Override - public String toString() { - return "[[DeferredEval<" + callback + ">]" + next + "]"; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/DeferredCallback.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/DeferredCallback.java deleted file mode 100644 index 3570872a821..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/DeferredCallback.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.callstack; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; - -/** - * An element for deferring and offloading validation and generation work for building the - * call stack. - * - * @author Mike Brock - */ -public interface DeferredCallback { - public void doDeferred(CallWriter writer, Context context, Statement statement); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/DefineLabel.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/DefineLabel.java deleted file mode 100644 index 5023abf3927..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/DefineLabel.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.callstack; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.control.branch.Label; - -/** - * @author Christian Sadilek - */ -public class DefineLabel extends AbstractCallElement { - private final String name; - - public DefineLabel(final String name) { - this.name = name; - } - - @Override - public void handleCall(final CallWriter writer, - final Context context, - final Statement statement) { - - final Label label = Label.create(name); - context.addLabel(label); - - writer.reset(); - writer.append(label.generate(context)); - } - - @Override - public String toString() { - return "[[Label<" + name + ">]" + next + "]"; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/DynamicLoad.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/DynamicLoad.java deleted file mode 100644 index 6feba4fa161..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/DynamicLoad.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.callstack; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.exception.GenerationException; -import org.jboss.errai.codegen.util.GenUtil; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public class DynamicLoad extends AbstractCallElement { - private final Object value; - - public DynamicLoad(final Object value) { - this.value = value; - } - - @Override - public void handleCall(final CallWriter writer, - final Context context, - final Statement statement) { - try { - nextOrReturn(writer, context, GenUtil.generate(context, value)); - } - catch (GenerationException e) { - blameAndRethrow(e); - } - } - - @Override - public String toString() { - return "[[DynamicLoad<" + value + ">]" + next + "]"; - } - - public Object getValue() { - return value; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/LoadClassReference.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/LoadClassReference.java deleted file mode 100644 index 2ec2600bdd0..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/LoadClassReference.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.callstack; - -import java.util.Map; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.RenderCacheStore; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.exception.GenerationException; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaParameterizedType; -import org.jboss.errai.codegen.meta.MetaType; - -/** - * {@link CallElement} to create a class reference. - * - * @author Christian Sadilek - */ -public class LoadClassReference extends AbstractCallElement { - private final MetaClass metaClass; - - public LoadClassReference(final MetaClass type) { - this.metaClass = type; - } - - @Override - public void handleCall(final CallWriter writer, - final Context context, - final Statement statement) { - writer.reset(); - - try { - nextOrReturn(writer, context, new ClassReference(metaClass)); - } - catch (final GenerationException e) { - blameAndRethrow(e); - } - } - - public static class ClassReference implements Statement { - private final MetaClass metaClass; - - public ClassReference(final MetaClass metaClass) { - this.metaClass = metaClass; - } - - @Override - public String generate(final Context context) { - return getClassReference(metaClass, context); - } - - @Override - public MetaClass getType() { - return metaClass; - } - } - - public static String getClassReference(final MetaType metaClass, final Context context) { - return getClassReference(metaClass, context, true); - } - - private static final RenderCacheStore CLASS_LITERAL_RENDER_CACHE = - () -> "CLASS_LITERAL_RENDER_CACHE"; - - public static String getClassReference(final MetaType metaClass, final Context context, final boolean typeParms) { - final Map cacheStore = context.getRenderingCache(CLASS_LITERAL_RENDER_CACHE); - - String result = cacheStore.get(metaClass); - - if (result == null) { - result = _getClassReference(metaClass, context, typeParms); - } - return result; - } - - private static String _getClassReference(final MetaType metaClass, final Context context, final boolean typeParms) { - - final MetaClass erased; - if (metaClass instanceof MetaClass) { - erased = ((MetaClass) metaClass).getErased(); - } - else { - return "Object"; - } - - String fqcn = erased.getCanonicalName(); - final int idx = fqcn.lastIndexOf('.'); - if (idx != -1) { - - if ((context.isAutoImportActive() || "java.lang".equals(erased.getPackageName())) - && !context.hasImport(erased)) { - context.addImport(erased); - } - - if (context.hasImport(erased)) { - fqcn = fqcn.substring(idx + 1); - } - } - - final StringBuilder buf = new StringBuilder(fqcn); - if (typeParms) { - buf.append(getClassReferencesForParameterizedTypes(((MetaClass) metaClass).getParameterizedType(), context)); - } - - return buf.toString(); - } - - private static final RenderCacheStore PARMTYPE_LITERAL_RENDER_CACHE = - () -> "PARMTYPE_LITERAL_RENDER_CACHE"; - - private static String getClassReferencesForParameterizedTypes(final MetaParameterizedType parameterizedType, - final Context context) { - final Map cacheStore = context.getRenderingCache(PARMTYPE_LITERAL_RENDER_CACHE); - - String result = cacheStore.get(parameterizedType); - - if (result == null) { - - final StringBuilder buf = new StringBuilder(64); - - if (parameterizedType != null && parameterizedType.getTypeParameters().length != 0) { - buf.append("<"); - - for (int i = 0; i < parameterizedType.getTypeParameters().length; i++) { - final MetaType typeParameter = parameterizedType.getTypeParameters()[i]; - - if (typeParameter instanceof MetaParameterizedType) { - final MetaParameterizedType parameterizedTypeParemeter = (MetaParameterizedType) typeParameter; - buf.append(getClassReference(parameterizedTypeParemeter.getRawType(), context)); - buf.append(getClassReferencesForParameterizedTypes(parameterizedTypeParemeter, context)); - } - else { - // fix to a weirdness in the GWT deferred bining API; - final String ref = getClassReference(typeParameter, context); - if ("Object".equals(ref)) { - // ignore; - return ""; - } - - buf.append(ref); - } - - if (i + 1 < parameterizedType.getTypeParameters().length) - buf.append(", "); - } - buf.append(">"); - } - - result = buf.toString(); - cacheStore.put(parameterizedType, result); - } - - return result; - - } - - @Override - public String toString() { - return "[[LoadClassReference<" + metaClass.getFullyQualifiedName() + ">]" + next + "]"; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/LoadField.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/LoadField.java deleted file mode 100644 index 81fe191c0cc..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/LoadField.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.callstack; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.VariableReference; -import org.jboss.errai.codegen.builder.impl.Scope; -import org.jboss.errai.codegen.exception.UndefinedFieldException; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.meta.MetaField; -import org.jboss.errai.codegen.meta.impl.build.BuildMetaField; - -/** - * @author Mike Brock - */ -public class LoadField extends AbstractCallElement { - private final String fieldName; - - public LoadField(final String fieldName) { - this.fieldName = fieldName; - } - - @Override - public void handleCall(final CallWriter writer, final Context context, Statement statement) { - final MetaField field; - if (fieldName.equals("this")) { - // TODO this is a workaround to access the enclosing instance of a type - field = new BuildMetaField(null, null, Scope.Private, statement.getType(), "this"); - } - else { - field = statement.getType().getInheritedField(fieldName); - } - - if (field == null) { - final UndefinedFieldException ufe = new UndefinedFieldException(fieldName, statement.getType()); - if (context.isPermissiveMode()) { - ufe.printStackTrace(); - } - else { - blameAndRethrow(ufe); - } - } - - final String currCallString = writer.getCallString(); - writer.reset(); - - statement = new VariableReference() { - - @Override - public String getName() { - return fieldName; - } - - @Override - public Statement getValue() { - return null; - } - - @Override - public String generate(final Context context) { - final StringBuilder buf = new StringBuilder(currCallString); - if (!currCallString.isEmpty()) { - buf.append("."); - } - return buf.append(getName()).toString(); - } - - @Override - public MetaClass getType() { - return field == null ? MetaClassFactory.get(Object.class) : field.getType(); - } - }; - - nextOrReturn(writer, context, statement); - } - - @Override - public String toString() { - return "[[LoadField<" + fieldName + ">]" + next + "]"; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/LoadLiteral.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/LoadLiteral.java deleted file mode 100644 index d4a80ecb159..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/LoadLiteral.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.callstack; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.exception.GenerationException; -import org.jboss.errai.codegen.literal.LiteralFactory; - -/** - * @author Mike Brock - */ -public class LoadLiteral extends AbstractCallElement { - private Object literalValue; - - public LoadLiteral(final Object literalValue) { - this.literalValue = literalValue; - } - - @Override - public void handleCall(final CallWriter writer, final Context context, final Statement statement) { - writer.reset(); - try { - nextOrReturn(writer, context, LiteralFactory.getLiteral(context, literalValue)); - } - catch (GenerationException e) { - blameAndRethrow(e); - } - } - - @Override - public String toString() { - return "[[Literal<" + literalValue + ">]" + next + "]"; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/LoadNested.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/LoadNested.java deleted file mode 100644 index 72735c05a21..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/LoadNested.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.callstack; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Mike Brock - */ -public class LoadNested extends AbstractCallElement { - private Statement statement; - - public LoadNested(final Statement statement) { - this.statement = new Statement() { - MetaClass type; - - String generatedCache; - - @Override - public String generate(final Context context) { - if (generatedCache != null) return generatedCache; - - final String res = statement.generate(context).trim(); - - type = statement.getType(); - - if (getNext() == null || (getNext() instanceof ReturnValue)) { - return generatedCache = res; - } - else if (isIdentifierOnly(res)) { - return generatedCache =res; - } - else { - return generatedCache = "(" + res + ")"; - } - } - - @Override - public MetaClass getType() { - return type; - } - - @Override - public String toString() { - return statement.toString(); - } - }; - } - - private static boolean isIdentifierOnly(final String s) { - for (int i = 0; i < s.length(); i++) { - if (!Character.isJavaIdentifierPart(s.charAt(0))) return false; - } - - return true; - } - - @Override - public void handleCall(final CallWriter writer, final Context context, final Statement statement) { - nextOrReturn(writer, context, this.statement); - } - - @Override - public String toString() { - return "[[Nest<" + statement + ">]" + next + "]"; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/LoadVariable.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/LoadVariable.java deleted file mode 100644 index 4a8325e965b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/LoadVariable.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.callstack; - -import java.util.Arrays; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.VariableReference; -import org.jboss.errai.codegen.exception.GenerationException; -import org.jboss.errai.codegen.exception.InvalidTypeException; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.util.GenUtil; - -/** - * {@link CallElement} to load {@link VariableReference}s. Indexes can be provided in case of an array. - * - * @author Mike Brock - * @author Christian Sadilek - */ -public class LoadVariable extends AbstractCallElement { - private final String variableName; - private final Object[] indexes; - private boolean classMember; - - public LoadVariable(final String variableName, final Object... indexes) { - this.variableName = variableName; - this.indexes = indexes == null ? new Object[0] : indexes; - } - - public LoadVariable(final String variableName, final boolean classMember, final Object... indexes) { - this(variableName, indexes); - this.classMember = classMember; - } - - @Override - public void handleCall(final CallWriter writer, final Context context, final Statement statement) { - writer.reset(); - - try { - final Statement[] idx = new Statement[this.indexes.length]; - for (int i = 0; i < idx.length; i++) { - idx[i] = GenUtil.convert(context, GenUtil.generate(context, this.indexes[i]), MetaClassFactory.get(Integer.class)); - } - - final VariableReference ref = context.getVariable(variableName); - - if (idx.length > 0) { - if (!ref.getType().isArray()) { - throw new InvalidTypeException("attempt to use indexed accessor on non-array type: " + ref); - } - } - - final Statement stmt = new VariableReference() { - @Override - public String getName() { - return ref.getName(); - } - - @Override - public Statement getValue() { - return ref.getValue(); - } - - String generatedCache; - - @Override - public String generate(final Context context) { - if (generatedCache != null) return generatedCache; - - if (variableName.equals("this") && next != null && !(next instanceof ReturnValue)) { - return generatedCache = ""; - } - - final StringBuilder buf = new StringBuilder((classMember - && context.isAmbiguous(ref.getName()) ? "this." : "").concat(getName())); - - Arrays.stream(idx).forEach(s -> buf.append('[').append(s.generate(context)).append(']')); - return generatedCache = buf.toString(); - } - - @Override - public MetaClass getType() { - final MetaClass ret; - - final int dims = GenUtil.getArrayDimensions(ref.getType()); - - if (ref.getType().isArray() && idx.length > 0) { - final int newDims = dims - idx.length; - if (newDims > 0) { - ret = ref.getType().getOuterComponentType().asArrayOf(dims - idx.length); - } - else { - ret = ref.getType().getOuterComponentType(); - } - } - else { - ret = ref.getType(); - } - - return ret; - } - }; - - ref.setIndexes(idx); - nextOrReturn(writer, context, stmt); - } - catch (final GenerationException e) { - blameAndRethrow(e); - } - } - - public String getVariableName() { - return variableName; - } - - @Override - public String toString() { - return "[[LoadVariable<" + variableName + ">]" + next + "]"; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/MethodCall.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/MethodCall.java deleted file mode 100644 index 0612b0cbf51..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/MethodCall.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.callstack; - -import java.util.Arrays; - -import org.jboss.errai.codegen.CallParameters; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.MethodInvocation; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.exception.GenerationException; -import org.jboss.errai.codegen.exception.UndefinedMethodException; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.meta.MetaMethod; -import org.jboss.errai.codegen.meta.MetaParameterizedType; -import org.jboss.errai.codegen.meta.MetaType; -import org.jboss.errai.codegen.meta.MetaTypeVariable; -import org.jboss.errai.codegen.util.GenUtil; - -import static org.jboss.errai.codegen.CallParameters.fromStatements; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public class MethodCall extends AbstractCallElement { - private final String methodName; - private final Object[] parameters; - private final boolean staticMethod; - - public MethodCall(final String methodName, final Object[] parameters) { - this.methodName = methodName; - this.parameters = parameters; - this.staticMethod = false; - } - - public MethodCall(final String methodName, final Object[] parameters, final boolean staticMethod) { - this.methodName = methodName; - this.parameters = parameters; - this.staticMethod = staticMethod; - } - - @Override - public void handleCall(final CallWriter writer, final Context context, Statement statement) { - try { - CallParameters callParams = fromStatements(GenUtil.generateCallParameters(context, parameters)); - - statement.generate(context); - - final MetaClass callType = statement.getType(); - - final MetaClass[] parameterTypes = callParams.getParameterTypes(); - final MetaMethod method = (staticMethod) ? callType.getBestMatchingStaticMethod(methodName, parameterTypes) - : callType.getBestMatchingMethod(methodName, parameterTypes); - - if (method == null) { - if (context.isPermissiveMode()) { - try { - blameAndRethrow( new UndefinedMethodException(statement.getType(), methodName, parameterTypes) ); - } - catch (final Exception e) { - e.printStackTrace(); - } - - dummyReturn(writer, context); - return; - } - else { - throw new UndefinedMethodException(statement.getType(), methodName, parameterTypes); - } - } - - if (method.getGenericParameterTypes() != null) { - final MetaType[] genTypes = method.getGenericParameterTypes(); - for (int i = 0; i < genTypes.length; i++) { - if (genTypes[i] instanceof MetaParameterizedType) { - if (parameters[i] instanceof MetaClass) { - final MetaType type = ((MetaParameterizedType) genTypes[i]).getTypeParameters()[0]; - if (type instanceof MetaTypeVariable) { - writer.recordTypeParm(((MetaTypeVariable) type).getName(), (MetaClass) parameters[i]); - } - } - } - } - } - - /** - * If the method is within the calling scope, we can strip the qualifying reference. - */ - if (statement instanceof LoadClassReference.ClassReference && context.isInScope(method)) { - writer.reset(); - } - - callParams = fromStatements(GenUtil.generateCallParameters(method, context, parameters)); - statement = new MethodInvocation(writer, callType, method, callParams); - - resultType = statement.getType(); - - nextOrReturn(writer, context, statement); - } - catch (final GenerationException ge) { - blameAndRethrow(ge); - } - catch (final Exception e) { - throw new RuntimeException("error generating method call for: " + methodName - + "(" + Arrays.toString(parameters) + ")", e); - } - } - - @Override - public String toString() { - return "[[MethodCall<" + methodName + "(" + Arrays.toString(parameters) + ")>]" + next + "]"; - } - - private void dummyReturn(final CallWriter writer, final Context context) { - nextOrReturn(writer, context, new Statement() { - @Override - public String generate(final Context context) { - final StringBuilder parms = new StringBuilder(); - for (int i = 0; i < parameters.length; i++) { - parms.append(GenUtil.generate(context, parameters[i])); - if (i + 1 < parameters.length) parms.append(", "); - } - return methodName + "(" + parms.toString() + ")"; - } - - @Override - public MetaClass getType() { - return MetaClassFactory.get(Object.class); - } - }); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/ResetCallElement.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/ResetCallElement.java deleted file mode 100644 index c1d4985e759..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/ResetCallElement.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.callstack; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; - -/** - * @author Mike Brock - */ -public class ResetCallElement extends AbstractCallElement { - @Override - public void handleCall(CallWriter writer, Context context, Statement statement) { - writer.reset(); - nextOrReturn(writer, context, null); - } - - @Override - public String toString() { - return "[StackReset] -> " + next; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/ReturnValue.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/ReturnValue.java deleted file mode 100644 index 2fd95578b00..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/ReturnValue.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.callstack; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; - -/** - * @author Mike Brock - */ -public class ReturnValue extends AbstractCallElement { - @Override - public void handleCall(CallWriter writer, Context context, Statement statement) { - resultType = statement.getType(); - writer.prepend("return "); - } - - @Override - public String toString() { - return "[Return]"; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/ThrowException.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/ThrowException.java deleted file mode 100644 index f498d3acb3d..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/callstack/ThrowException.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.callstack; - -import org.jboss.errai.codegen.AbstractStatement; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.VariableReference; -import org.jboss.errai.codegen.builder.impl.ObjectBuilder; -import org.jboss.errai.codegen.exception.GenerationException; -import org.jboss.errai.codegen.exception.InvalidTypeException; - -/** - * @author Christian Sadilek - */ -public class ThrowException extends AbstractCallElement { - private String exceptionVariableName; - - private Class throwableType; - private Object[] parameters; - - public ThrowException(String exceptionVariableName) { - this.exceptionVariableName = exceptionVariableName; - this.parameters = new Object[0]; - } - - public ThrowException(Class throwableType, Object... parameters) { - this.throwableType = throwableType; - this.parameters = parameters; - } - - @Override - public void handleCall(CallWriter writer, Context context, Statement statement) { - statement = new AbstractStatement() { - @Override - public String generate(Context context) { - StringBuilder buf = new StringBuilder(); - try { - buf.append("throw "); - if (throwableType != null) { - buf.append(ObjectBuilder.newInstanceOf(throwableType).withParameters(parameters).generate(context)); - } - else { - VariableReference exceptionVar = context.getVariable(exceptionVariableName); - if (!exceptionVar.getType().isAssignableTo(Throwable.class)) { - throw new InvalidTypeException("Variable " + exceptionVariableName + " is not a Throwable"); - } - buf.append(exceptionVar.generate(context)); - } - } - catch (GenerationException e) { - blameAndRethrow(e); - } - - return buf.toString(); - } - }; - - writer.reset(); - writer.append(statement.generate(context)); - } - - @Override - public String toString() { - return "[Throw<" + throwableType.getName() + ">]"; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/AbstractStatementBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/AbstractStatementBuilder.java deleted file mode 100644 index fa653015692..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/AbstractStatementBuilder.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.impl; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.builder.Builder; -import org.jboss.errai.codegen.builder.StatementEnd; -import org.jboss.errai.codegen.builder.callstack.CallElement; -import org.jboss.errai.codegen.builder.callstack.CallWriter; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.util.GenUtil; - -import static org.jboss.errai.codegen.util.PrettyPrinter.prettyPrintJava; - -/** - * Base class of all {@link StatementBuilder}s - * - * @author Christian Sadilek - */ -public abstract class AbstractStatementBuilder implements Statement, Builder, StatementEnd { - protected final Context context; - protected final CallElementBuilder callElementBuilder; - protected boolean generated; - - protected AbstractStatementBuilder(final Context context) { - this(context, new CallElementBuilder()); - } - - protected AbstractStatementBuilder(Context context, final CallElementBuilder callElementBuilder) { - if (context == null) { - context = Context.create(); - } - - this.context = context; - this.callElementBuilder = callElementBuilder; - } - - String generatorCache; - - @Override - public String generate(final Context context) { - if (generatorCache != null) return generatorCache; - - final CallWriter writer = new CallWriter(); - try { - callElementBuilder.getRootElement().handleCall(writer, context, null); - } - catch (Exception e) { - GenUtil.throwIfUnhandled("generation failure at: " + writer.getCallString(), e); - } - generated = true; - - return generatorCache = prettyPrintJava(writer.getCallString()); - } - - public void appendCallElement(final CallElement element) { - callElementBuilder.appendCallElement(element); - } - - @Override - public MetaClass getType() { - if (callElementBuilder.getCallElement() == null) - return null; - - return callElementBuilder.getCallElement().getResultType(); - } - - @Override - public String toJavaString() { - return generate(context); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/AnonymousClassStructureBuilderImpl.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/AnonymousClassStructureBuilderImpl.java deleted file mode 100644 index d8b954bb04c..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/AnonymousClassStructureBuilderImpl.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.impl; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.jboss.errai.codegen.AbstractStatement; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.DefParameters; -import org.jboss.errai.codegen.Parameter; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.Variable; -import org.jboss.errai.codegen.builder.AnonymousClassStructureBuilder; -import org.jboss.errai.codegen.builder.BlockBuilder; -import org.jboss.errai.codegen.builder.BuildCallback; -import org.jboss.errai.codegen.exception.UndefinedMethodException; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaMethod; -import org.jboss.errai.codegen.meta.impl.build.BuildMetaClass; -import org.jboss.errai.codegen.util.GenUtil; - -import static org.jboss.errai.codegen.builder.callstack.LoadClassReference.getClassReference; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public class AnonymousClassStructureBuilderImpl - extends ClassBuilder - implements AnonymousClassStructureBuilder { - private final BuildCallback callback; - private final List deferredGenerateCallbacks; - private final Context context; - - AnonymousClassStructureBuilderImpl(final MetaClass clazz, final BuildCallback builderBuildCallback) { - super(clazz.getFullyQualifiedName(), clazz, builderBuildCallback.getParentContext()); - this.callback = builderBuildCallback; - this.context = builderBuildCallback.getParentContext(); - deferredGenerateCallbacks = new ArrayList(); - } - - @Override - public BlockBuilder initialize() { - return new BlockBuilderImpl( - new BuildCallback() { - @Override - public AnonymousClassStructureBuilderImpl callback(final Statement statement) { - - addCallable(context -> { - final StringBuilder buf = new StringBuilder(256); - buf.append("{\n"); - if (statement != null) { - buf.append(statement.generate(Context.create(context))).append("\n"); - } - buf.append("}\n"); - - return buf.toString(); - }); - - return AnonymousClassStructureBuilderImpl.this; - } - - @Override - public Context getParentContext() { - return context; - } - }); - } - - private BlockBuilder publicOverridesMethod(final MetaMethod method, - final DefParameters parameters) { - return new BlockBuilderImpl( - new BuildCallback() { - @Override - public AnonymousClassStructureBuilder callback(final Statement statement) { - - addCallable(context -> { - final Context subContext = Context.create(context); - parameters.getParameters() - .forEach(p -> subContext.addVariable(Variable.create(p.getName(), p.getType()))); - - final StringBuilder buf = new StringBuilder(256); - final String returnType = getClassReference(method.getReturnType(), context); - - buf.append("public ").append(returnType) - .append(" ") - .append(method.getName()) - .append(parameters.generate(context)).append(" {\n"); - if (statement != null) { - buf.append(statement.generate(subContext)).append("\n"); - } - buf.append("}\n"); - - return buf.toString(); - }); - - return AnonymousClassStructureBuilderImpl.this; - } - - @Override - public Context getParentContext() { - return context; - } - }); - } - - @Override - public BlockBuilder publicOverridesMethod(final String name, final Parameter... args) { - final List types = new ArrayList(); - Arrays.stream(args).forEach(a -> types.add(a.getType())); - final MetaMethod method = classDefinition.getSuperClass() - .getBestMatchingMethod(name, types.toArray(new MetaClass[args.length])); - - if (method == null) - throw new UndefinedMethodException("Can't override (inherited method not found):" - + classDefinition.getFullyQualifiedNameWithTypeParms() + "." + name + "(" + types + ")"); - - return publicOverridesMethod(method, DefParameters.fromParameters(args)); - } - - - @Override - public ObjectBuilder finish() { - if (callback != null) { - return callback.callback(new AbstractStatement() { - @Override - public String generate(final Context context) { - context.attachClass(getClassDefinition()); - return doGenerate(context); - } - }); - } - - return null; - } - - private void addCallable(final DeferredGenerateCallback callable) { - deferredGenerateCallbacks.add(callable); - } - - String generatedCache; - - private String doGenerate(final Context context) { - if (generatedCache != null) return generatedCache; - try { - if (deferredGenerateCallbacks == null) - return null; - - final Context subContext = Context.create(context); - - classDefinition.getContext().getDeclaredVariables().forEach((v) -> subContext.addVariable(v)); - subContext.addVariable(Variable.create("this", getClassDefinition())); - classDefinition.setContext(subContext); - - final StringBuilder buf = new StringBuilder(256); - buf.append(classDefinition.membersToString().trim()).append("\n"); - deferredGenerateCallbacks.forEach(c -> buf.append(c.doGenerate(subContext).trim()).append('\n')); - return generatedCache = buf.toString().trim(); - } - catch (final Exception e) { - GenUtil.throwIfUnhandled("while generating: " + classDefinition.getFullyQualifiedName(), e); - return null; - } - } - - public static interface DeferredGenerateCallback { - public String doGenerate(Context context); - } - - - @Override - public BuildMetaClass getClassDefinition() { - return classDefinition; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/ArithmeticExpressionBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/ArithmeticExpressionBuilder.java deleted file mode 100644 index 4de5005d076..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/ArithmeticExpressionBuilder.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.impl; - -import org.jboss.errai.codegen.ArithmeticExpression; -import org.jboss.errai.codegen.ArithmeticOperator; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; - -/** - * @author Christian Sadilek - */ -public class ArithmeticExpressionBuilder extends ExpressionBuilder implements ArithmeticExpression { - - public ArithmeticExpressionBuilder() {} - - public ArithmeticExpressionBuilder(Statement rhs, ArithmeticOperator operator) { - super(rhs, operator); - } - - public ArithmeticExpressionBuilder(Object rhs, ArithmeticOperator operator) { - super(rhs, operator); - } - - public ArithmeticExpressionBuilder(Statement lhs, Statement rhs, ArithmeticOperator operator) { - super(lhs, rhs, operator); - } - - public ArithmeticExpressionBuilder(Object lhs, Object rhs, ArithmeticOperator operator) { - super(lhs, rhs, operator); - } - - public static ArithmeticExpression create(Statement lhs) { - return new ArithmeticExpressionBuilder(lhs, null, null); - } - - public static ArithmeticExpression create(ArithmeticOperator operator, Object rhs) { - return new ArithmeticExpressionBuilder(rhs, operator); - } - - public static ArithmeticExpression create(Object lhs, ArithmeticOperator operator, Object rhs) { - return new ArithmeticExpressionBuilder(lhs, rhs, operator); - } - - @Override - public MetaClass getType() { - Class lhsType = null; - if (lhs != null) { - lhsType = lhs.getType().asUnboxed().asClass(); - } - Class rhsType = null; - if (rhs != null) { - rhsType = rhs.getType().asUnboxed().asClass(); - } - return MetaClassFactory.get(promote(lhsType, rhsType)); - } - - /** - * Implements unary or binary numeric promotion according to the JLS. - * - * @param lhs - * the left-hand-side type as an unboxed numeric type. Can be null if - * there is no left-hand-side operand. - * @param lhs - * the right-hand-side type as an unboxed numeric type. Can be null - * if there is no right-hand-side operand. - * @return The unboxed numeric class type that the expression results in. - */ - private Class promote(Class lhs, Class rhs) { - if (lhs == double.class || rhs == double.class) { - return double.class; - } - if (lhs == float.class || rhs == float.class) { - return float.class; - } - if (lhs == long.class || rhs == long.class) { - return long.class; - } - return int.class; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/ArrayBuilderImpl.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/ArrayBuilderImpl.java deleted file mode 100644 index c6bb1953edb..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/ArrayBuilderImpl.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.impl; - -import java.lang.reflect.Array; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.builder.ArrayBuilder; -import org.jboss.errai.codegen.builder.ArrayInitializationBuilder; -import org.jboss.errai.codegen.builder.callstack.LoadClassReference; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.util.GenUtil; - -/** - * StatementBuilder to create and initialize Arrays. - * - * @author Christian Sadilek - * @author Mike Brock - */ -public class ArrayBuilderImpl extends AbstractStatementBuilder implements ArrayBuilder, ArrayInitializationBuilder { - private MetaClass type; - private MetaClass componentType; - private Object[] dimensions; - private Object values = null; - - protected ArrayBuilderImpl(Context context, CallElementBuilder callElementBuilder) { - super(context, callElementBuilder); - } - - @Override - public ArrayInitializationBuilder newArray(MetaClass componentType, Object... dimensions) { - this.type = componentType.asArrayOf(dimensions.length == 0 ? 1 : dimensions.length); - this.componentType = componentType; - this.dimensions = dimensions; - return this; - } - - @Override - public ArrayInitializationBuilder newArray(Class componentType, Object... dimensions) { - return newArray(MetaClassFactory.get(componentType), dimensions); - } - - @Override - public AbstractStatementBuilder initialize(Object... values) { - if (values.length == 1 && values[0].getClass().isArray() - && values.getClass().getComponentType().equals(Object.class)) { - // this is a workaround for the jdt compiler which is coercing a multi-dimensional array - // into the first element of our vararg instead of flattening it out (like javac does). - this.values = values[0]; - } - else { - this.values = values; - } - - return this; - } - - @Override - public MetaClass getType() { - return type; - } - - @Override - public String generate(Context context) { - if (generatorCache != null) return generatorCache; - - StringBuilder buf = new StringBuilder(128); - buf.append("new ").append(LoadClassReference.getClassReference(componentType, context)); - - if (values != null) { - generateWithInitialization(context, buf); - } - else { - int i = 0; - - for (Object dimension : dimensions) { - try { - if (dimension == null) { - if (i == 0) { - i--; - break; - } - else { - buf.append("[]"); - } - } - else { - buf.append("[").append(GenUtil.generate(context, dimension).generate(context)).append("]"); - } - } - finally { - i++; - } - } - - if (i == 0) { - throw new RuntimeException("Must provide either dimension expressions or an array initializer"); - } - } - - return generatorCache = buf.toString(); - } - - private void generateWithInitialization(Context context, StringBuilder buf) { - int dim = 0; - Class type = values.getClass(); - while (type.isArray()) { - dim++; - type = type.getComponentType(); - } - - for (int i = 0; i < dim; i++) { - buf.append("[]"); - } - buf.append(" "); - - generateInitialization(context, buf, values); - } - - private void generateInitialization(Context context, StringBuilder buf, Object values) { - buf.append("{ "); - int length = Array.getLength(values); - for (int i = 0; i < length; i++) { - Object element = Array.get(values, i); - if (element.getClass().isArray()) { - generateInitialization(context, buf, element); - } - else { - Statement statement = GenUtil.generate(context, element); - String statementExpr = statement.generate(context); - GenUtil.assertAssignableTypes(context, statement.getType(), componentType); - buf.append(statementExpr); - } - if (i + 1 < length) { - buf.append(", "); - } - } - buf.append(" }"); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/AssignmentBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/AssignmentBuilder.java deleted file mode 100644 index 2421aceafd2..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/AssignmentBuilder.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.impl; - -import java.util.Arrays; - -import org.jboss.errai.codegen.AssignmentOperator; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.VariableReference; -import org.jboss.errai.codegen.exception.InvalidTypeException; -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * {@link StatementBuilder} that generates {@link VariableReference} assignments. - * - * @author Mike Brock - * @author Christian Sadilek - */ -public class AssignmentBuilder implements Statement { - protected boolean isFinal; - - protected final AssignmentOperator operator; - protected final VariableReference reference; - protected final Statement statement; - - public AssignmentBuilder(final boolean isFinal, - final AssignmentOperator operator, - final VariableReference reference, - final Statement statement) { - this.isFinal = isFinal; - this.operator = operator; - this.reference = reference; - this.statement = statement; - } - - @Override - public String generate(final Context context) { - MetaClass referenceType = reference.getType(); - final Statement[] indexes = reference.getIndexes(); - if (indexes!=null) { - for (final Statement index : indexes) { - if (!referenceType.isArray()) - throw new InvalidTypeException("Variable is not a " + indexes.length + "-dimensional array!"); - referenceType = referenceType.getComponentType(); - } - } - operator.assertCanBeApplied(referenceType); - operator.assertCanBeApplied(statement.getType()); - - return reference.generate(context) + generateIndexes(context, indexes) + - " " + operator.getCanonicalString() + " " + statement.generate(context); - } - - private String generateIndexes(final Context context, final Statement[] indexes) { - if (indexes==null || indexes.length == 0) return ""; - - final StringBuilder buf = new StringBuilder(128); - Arrays.stream(indexes).forEach(index -> buf.append("[").append(index.generate(context)).append("]")); - return buf.toString(); - } - - @Override - public MetaClass getType() { - return reference.getType(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/BitwiseExpressionBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/BitwiseExpressionBuilder.java deleted file mode 100644 index 3944274a277..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/BitwiseExpressionBuilder.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.impl; - -import org.jboss.errai.codegen.BitwiseOperator; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Expression; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.util.GenUtil; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public class BitwiseExpressionBuilder extends ExpressionBuilder { - public BitwiseExpressionBuilder(final Statement lhs, final Statement rhs, final BitwiseOperator operator) { - super(lhs, rhs, operator); - } - - public BitwiseExpressionBuilder(final Object lhs, final Object rhs, final BitwiseOperator operator) { - super(lhs, rhs, operator); - } - - public static Expression create(final Statement lhs) { - return new BitwiseExpressionBuilder(lhs, null, null); - } - - public static Expression create(final BitwiseOperator operator, final Object rhs) { - return create(null, operator, rhs); - } - - public static Expression create(final Object lhs, final BitwiseOperator operator, final Object rhs) { - return new BitwiseExpressionBuilder(lhs, rhs, operator); - } - - public static Expression createUnqualifying(final Object lhs, final BitwiseOperator operator, final Object rhs) { - final BitwiseExpressionBuilder bitwiseExpressionBuilder = new BitwiseExpressionBuilder(lhs, rhs, operator); - bitwiseExpressionBuilder.qualifyingBrackets = false; - return bitwiseExpressionBuilder; - } - - @Override - public String generate(final Context context) { - if (operator == null) { - lhs = GenUtil.generate(context, lhs); - lhs = GenUtil.convert(context, lhs, MetaClassFactory.get(Boolean.class)); - } - - return super.generate(context); - } - - @Override - public MetaClass getType() { - return lhs.getType(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/BlockBuilderImpl.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/BlockBuilderImpl.java deleted file mode 100644 index a22b85bcd4b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/BlockBuilderImpl.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.impl; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -import org.jboss.errai.codegen.BlockStatement; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.InnerClass; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.builder.BlockBuilder; -import org.jboss.errai.codegen.builder.BuildCallback; -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public class BlockBuilderImpl implements BlockBuilder { - protected final BlockStatement blockStatement; - protected final BuildCallback callback; - - public BlockBuilderImpl() { - this(null); - } - - public BlockBuilderImpl(final BuildCallback callback) { - this(new BlockStatement(), callback); - } - - public BlockBuilderImpl(final BlockStatement blockStatement, final BuildCallback callback) { - this.blockStatement = blockStatement; - this.callback = callback; - } - - @Override - public void insertBefore(final Statement stmt) { - this.blockStatement.insertBefore(stmt); - } - - @Override - public void insertBefore(final InnerClass innerClass) { - insertBefore(new Statement() { - - @Override - public String generate(final Context context) { - return innerClass.generate(context); - } - - @Override - public MetaClass getType() { - return innerClass.getType(); - } - }); - } - - @Override - public BlockBuilder append(final Statement statement) { - blockStatement.addStatement(statement); - return this; - } - - @Override - public BlockBuilder appendAll(Collection stmt) { - blockStatement.addAllStatements(stmt); - return this; - } - - @Override - public BlockBuilder append(final InnerClass innerClass) { - blockStatement.addStatement(new Statement() { - - @Override - public String generate(final Context context) { - return innerClass.generate(context); - } - - @Override - public MetaClass getType() { - return innerClass.getType(); - } - }); - return this; - } - - @Override - public BlockBuilder _(final Statement stmt) { - return append(stmt); - } - - @Override - public BlockBuilder _(final InnerClass innerClass) { - return append(innerClass); - } - - @Override - public List splitFrom(final Statement statement) { - final List statements = blockStatement.getStatements(); - final int index = statements.indexOf(statement); - - if (index > 0) { - final List split = new ArrayList(statements.subList(index, statements.size())); - statements.removeAll(split); - return split; - } - else { - return Collections.emptyList(); - } - } - - @Override - public Statement peek() { - final List statements = blockStatement.getStatements(); - return statements.isEmpty() ? null : statements.get(statements.size() - 1); - } - - @Override - public Iterator iterator() { - return blockStatement.getStatements().iterator(); - } - - @Override - public T finish() { - if (callback != null) { - return callback.callback(blockStatement); - } - return null; - } - - @Override - public void clear() { - blockStatement.getStatements().clear(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/BooleanExpressionBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/BooleanExpressionBuilder.java deleted file mode 100644 index f1868718e53..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/BooleanExpressionBuilder.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.impl; - -import org.jboss.errai.codegen.BooleanExpression; -import org.jboss.errai.codegen.BooleanOperator; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.UnaryOperator; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.util.GenUtil; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public class BooleanExpressionBuilder extends ExpressionBuilder implements BooleanExpression { - private boolean negated; - - public BooleanExpressionBuilder() {} - - public BooleanExpressionBuilder(final Statement rhs, final BooleanOperator operator) { - super(rhs, operator); - } - - public BooleanExpressionBuilder(final Statement lhs, final Statement rhs, final BooleanOperator operator) { - super(lhs, rhs, operator); - } - - public BooleanExpressionBuilder(final Object lhs, final Object rhs, final BooleanOperator operator) { - super(lhs, rhs, operator); - } - - public static BooleanExpression create(final Statement lhs) { - return new BooleanExpressionBuilder(lhs, null, null); - } - - public static BooleanExpression create(final BooleanOperator operator, final Object rhs) { - return create(null, operator, rhs); - } - - public static BooleanExpression create(final Object lhs, final BooleanOperator operator, final Object rhs) { - return new BooleanExpressionBuilder(lhs, rhs, operator); - } - - @Override - public String generate(final Context context) { - if (operator == null) { - lhs = GenUtil.generate(context, lhs); - lhs = GenUtil.convert(context, lhs, MetaClassFactory.get(Boolean.class)); - } - - if (negated) { - return UnaryOperator.Complement.getCanonicalString().concat("(") + super.generate(context).concat(")"); - } - - return super.generate(context); - } - - @Override - public MetaClass getType() { - return MetaClassFactory.get(boolean.class); - } - - @Override - public BooleanExpression negate() { - this.negated = !negated; - return this; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/CallElementBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/CallElementBuilder.java deleted file mode 100644 index 1ca27c2512d..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/CallElementBuilder.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.impl; - -import org.jboss.errai.codegen.builder.callstack.CallElement; - -/** - * @author Mike Brock - */ -public class CallElementBuilder { - protected CallElement rootElement; - protected CallElement callElement; - - public void appendCallElement(final CallElement element) { - if (callElement == null) { - rootElement = callElement = element; - } - else { - callElement = callElement.setNext(element); - } - } - - public CallElement getRootElement() { - return rootElement; - } - - public CallElement getCallElement() { - return callElement; - } - - @Override - public String toString() { - return rootElement == null ? "" : rootElement.toString(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/ClassBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/ClassBuilder.java deleted file mode 100644 index b1395380abd..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/ClassBuilder.java +++ /dev/null @@ -1,522 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.impl; - -import java.lang.annotation.Annotation; -import java.util.List; - -import org.jboss.errai.codegen.BlockStatement; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.DefModifiers; -import org.jboss.errai.codegen.DefParameters; -import org.jboss.errai.codegen.InnerClass; -import org.jboss.errai.codegen.Parameter; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.ThrowsDeclaration; -import org.jboss.errai.codegen.builder.BuildCallback; -import org.jboss.errai.codegen.builder.ClassDefinitionBuilderAbstractOption; -import org.jboss.errai.codegen.builder.ClassDefinitionBuilderCommentOption; -import org.jboss.errai.codegen.builder.ClassDefinitionBuilderInterfaces; -import org.jboss.errai.codegen.builder.ClassDefinitionBuilderScope; -import org.jboss.errai.codegen.builder.ClassDefinitionStaticOption; -import org.jboss.errai.codegen.builder.ClassStructureBuilder; -import org.jboss.errai.codegen.builder.ClassStructureBuilderAbstractMethodOption; -import org.jboss.errai.codegen.builder.ConstructorBlockBuilder; -import org.jboss.errai.codegen.builder.DefaultClassStructureBuilder; -import org.jboss.errai.codegen.builder.FieldBuildStart; -import org.jboss.errai.codegen.builder.MethodBuildCallback; -import org.jboss.errai.codegen.builder.MethodCommentBuilder; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.meta.impl.build.BuildMetaClass; -import org.jboss.errai.codegen.meta.impl.build.BuildMetaConstructor; -import org.jboss.errai.codegen.meta.impl.build.BuildMetaField; -import org.jboss.errai.codegen.meta.impl.build.BuildMetaMethod; -import org.jboss.errai.codegen.util.GenUtil; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public class ClassBuilder> implements - ClassDefinitionBuilderCommentOption, - ClassDefinitionBuilderScope, - ClassDefinitionStaticOption, - ClassStructureBuilder { - - protected final BuildMetaClass classDefinition; - - ClassBuilder(final String className, final MetaClass parent, final Context context) { - this.classDefinition = new BuildMetaClass(context, className); - this.classDefinition.setSuperClass(parent); - context.attachClass(classDefinition); - } - - ClassBuilder(final ClassBuilder that, final Context context) { - this.classDefinition = that.classDefinition; - this.classDefinition.setContext(context); - context.attachClass(classDefinition); - } - - public static ClassDefinitionBuilderCommentOption define(final String fullyQualifiedName) { - return new ClassBuilder(fullyQualifiedName, null, Context.create().autoImport()); - } - - public static ClassDefinitionBuilderCommentOption define(final String fullQualifiedName, final MetaClass parent) { - return new ClassBuilder(fullQualifiedName, parent, Context.create().autoImport()); - } - - public static ClassDefinitionBuilderCommentOption define(final String fullQualifiedName, final Class parent) { - return define(fullQualifiedName, MetaClassFactory.get(parent)); - } - - public static ClassStructureBuilder implement(final MetaClass cls) { - return new ClassBuilder(cls.getFullyQualifiedName() + "Impl", null, Context.create() - .autoImport()) - .publicScope() - .implementsInterface(cls).body(); - } - - public static ClassStructureBuilder implement(final Class cls) { - return implement(MetaClassFactory.get(cls)); - } - - @Override - public ClassBuilderAbstractMethodOption abstractClass() { - classDefinition.setAbstract(true); - return new ClassBuilderAbstractMethodOption(this, classDefinition.getContext()); - } - - @Override - public ClassDefinitionBuilderInterfaces interfaceDefinition() { - classDefinition.setInterface(true); - return new ClassBuilderAbstractMethodOption(this, classDefinition.getContext()); - - } - - public ClassBuilder importsClass(final Class clazz) { - return importsClass(MetaClassFactory.get(clazz)); - } - - public ClassBuilder importsClass(final MetaClass clazz) { - classDefinition.getContext().addImport(clazz); - return this; - } - - @Override - public ClassDefinitionBuilderInterfaces implementsInterface(final Class clazz) { - return implementsInterface(MetaClassFactory.get(clazz)); - } - - @Override - public ClassDefinitionBuilderInterfaces implementsInterface(final MetaClass clazz) { - if (!clazz.isInterface()) { - throw new RuntimeException("not an interface: " + clazz.getFullyQualifiedName()); - } - - classDefinition.addInterface(clazz); - return this; - } - - @Override - public ClassStructureBuilder body() { - return this; - } - - @Override - public ClassDefinitionBuilderScope classComment(String comment) { - classDefinition.setClassComment(comment); - return this; - } - - @Override - public ClassDefinitionStaticOption publicScope() { - classDefinition.setScope(Scope.Public); - return this; - } - - @Override - public ClassDefinitionStaticOption privateScope() { - classDefinition.setScope(Scope.Private); - return this; - } - - @Override - public ClassDefinitionStaticOption protectedScope() { - classDefinition.setScope(Scope.Protected); - return this; - } - - @Override - public ClassDefinitionStaticOption packageScope() { - classDefinition.setScope(Scope.Package); - return this; - } - - @Override - public ClassDefinitionBuilderAbstractOption staticClass() { - classDefinition.setStatic(true); - return this; - } - - @Override - public ConstructorBlockBuilder publicConstructor() { - return genConstructor(Scope.Public, DefParameters.none()); - } - - @Override - public ConstructorBlockBuilder publicConstructor(final MetaClass... parms) { - return genConstructor(Scope.Public, DefParameters.fromTypeArray(parms)); - } - - @Override - public ConstructorBlockBuilder publicConstructor(final Class... parms) { - return publicConstructor(MetaClassFactory.fromClassArray(parms)); - } - - @Override - public ConstructorBlockBuilder publicConstructor(final Parameter... parms) { - return genConstructor(Scope.Public, DefParameters.fromParameters(parms)); - } - - @Override - public ConstructorBlockBuilder privateConstructor() { - return genConstructor(Scope.Private, DefParameters.none()); - } - - @Override - public ConstructorBlockBuilder privateConstructor(final MetaClass... parms) { - return genConstructor(Scope.Private, DefParameters.fromTypeArray(parms)); - } - - @Override - public ConstructorBlockBuilder privateConstructor(final Class... parms) { - return privateConstructor(MetaClassFactory.fromClassArray(parms)); - } - - @Override - public ConstructorBlockBuilder privateConstructor(final Parameter... parms) { - return genConstructor(Scope.Private, DefParameters.fromParameters(parms)); - } - - @Override - public ConstructorBlockBuilder protectedConstructor() { - return genConstructor(Scope.Protected, DefParameters.none()); - } - - @Override - public ConstructorBlockBuilder protectedConstructor(final MetaClass... parms) { - return genConstructor(Scope.Protected, DefParameters.fromTypeArray(parms)); - } - - @Override - public ConstructorBlockBuilder protectedConstructor(final Class... parms) { - return protectedConstructor(MetaClassFactory.fromClassArray(parms)); - } - - @Override - public ConstructorBlockBuilder protectedConstructor(final Parameter... parms) { - return genConstructor(Scope.Protected, DefParameters.fromParameters(parms)); - } - - @Override - public ConstructorBlockBuilder packageConstructor() { - return genConstructor(Scope.Package, DefParameters.none()); - } - - @Override - public ConstructorBlockBuilder packageConstructor(final MetaClass... parms) { - return genConstructor(Scope.Package, DefParameters.fromTypeArray(parms)); - } - - @Override - public ConstructorBlockBuilder packageConstructor(final Class... parms) { - return packageConstructor(MetaClassFactory.fromClassArray(parms)); - } - - @Override - public ConstructorBlockBuilder packageConstructor(final Parameter... parms) { - return genConstructor(Scope.Package, DefParameters.fromParameters(parms)); - } - - private ConstructorBlockBuilder genConstructor(final Scope scope, final DefParameters - defParameters) { - return new ConstructorBlockBuilderImpl(new BuildCallback() { - - @Override - public T callback(final Statement statement) { - final BuildMetaConstructor buildMetaConstructor = - new BuildMetaConstructor(classDefinition, statement, defParameters); - buildMetaConstructor.setScope(scope); - - classDefinition.addConstructor(buildMetaConstructor); - return (T) ClassBuilder.this; - } - - @Override - public Context getParentContext() { - return classDefinition.getContext(); - } - }); - } - - // public method // - @Override - public MethodCommentBuilder publicMethod(final MetaClass returnType, final String name) { - return genMethod(Scope.Public, returnType, name, DefParameters.none()); - } - - @Override - public MethodCommentBuilder publicMethod(final Class returnType, final String name) { - return publicMethod(MetaClassFactory.get(returnType), name); - } - - @Override - public MethodCommentBuilder publicMethod(final MetaClass returnType, final String name, final MetaClass... parms) { - return genMethod(Scope.Public, returnType, name, DefParameters.fromTypeArray(parms)); - } - - @Override - public MethodCommentBuilder publicMethod(final Class returnType, final String name, final Class... parms) { - return publicMethod(MetaClassFactory.get(returnType), name, MetaClassFactory.fromClassArray(parms)); - } - - @Override - public MethodCommentBuilder publicMethod(final MetaClass returnType, final String name, final Parameter... parms) { - return genMethod(Scope.Public, returnType, name, DefParameters.fromParameters(parms)); - } - - @Override - public MethodCommentBuilder publicMethod(final Class returnType, final String name, final Parameter... parms) { - return publicMethod(MetaClassFactory.get(returnType), name, parms); - } - - // private method // - @Override - public MethodCommentBuilder privateMethod(final MetaClass returnType, final String name) { - return genMethod(Scope.Private, returnType, name, DefParameters.none()); - } - - @Override - public MethodCommentBuilder privateMethod(final Class returnType, final String name) { - return privateMethod(MetaClassFactory.get(returnType), name); - } - - @Override - public MethodCommentBuilder privateMethod(final MetaClass returnType, final String name, final MetaClass... parms) { - return genMethod(Scope.Private, returnType, name, DefParameters.fromTypeArray(parms)); - } - - @Override - public MethodCommentBuilder privateMethod(final Class returnType, final String name, final Class... parms) { - return privateMethod(MetaClassFactory.get(returnType), name, MetaClassFactory.fromClassArray(parms)); - } - - @Override - public MethodCommentBuilder privateMethod(final MetaClass returnType, final String name, final Parameter... parms) { - return genMethod(Scope.Private, returnType, name, DefParameters.fromParameters(parms)); - } - - @Override - public MethodCommentBuilder privateMethod(final Class returnType, final String name, final Parameter... parms) { - return privateMethod(MetaClassFactory.get(returnType), name, parms); - } - - // protected method // - @Override - public MethodCommentBuilder protectedMethod(final MetaClass returnType, final String name) { - return genMethod(Scope.Protected, returnType, name, DefParameters.none()); - } - - @Override - public MethodCommentBuilder protectedMethod(final Class returnType, final String name) { - return protectedMethod(MetaClassFactory.get(returnType), name); - } - - @Override - public MethodCommentBuilder protectedMethod(final MetaClass returnType, final String name, final MetaClass... parms) { - return genMethod(Scope.Protected, returnType, name, DefParameters.fromTypeArray(parms)); - } - - @Override - public MethodCommentBuilder protectedMethod(final Class returnType, final String name, final Class... parms) { - return protectedMethod(MetaClassFactory.get(returnType), name, MetaClassFactory.fromClassArray(parms)); - } - - @Override - public MethodCommentBuilder protectedMethod(final MetaClass returnType, final String name, final Parameter... parms) { - return genMethod(Scope.Protected, returnType, name, DefParameters.fromParameters(parms)); - } - - @Override - public MethodCommentBuilder protectedMethod(final Class returnType, final String name, final Parameter... parms) { - return protectedMethod(MetaClassFactory.get(returnType), name, parms); - } - - // package-private method // - @Override - public MethodCommentBuilder packageMethod(final MetaClass returnType, final String name) { - return genMethod(Scope.Package, returnType, name, DefParameters.none()); - } - - @Override - public MethodCommentBuilder packageMethod(final Class returnType, final String name) { - return packageMethod(MetaClassFactory.get(returnType), name); - } - - @Override - public MethodCommentBuilder packageMethod(final MetaClass returnType, final String name, final MetaClass... parms) { - return genMethod(Scope.Package, returnType, name, DefParameters.fromTypeArray(parms)); - } - - @Override - public MethodCommentBuilder packageMethod(final Class returnType, final String name, final Class... parms) { - return packageMethod(MetaClassFactory.get(returnType), name, MetaClassFactory.fromClassArray(parms)); - } - - @Override - public MethodCommentBuilder packageMethod(final MetaClass returnType, final String name, final Parameter... parms) { - return genMethod(Scope.Package, returnType, name, DefParameters.fromParameters(parms)); - } - - @Override - public MethodCommentBuilder packageMethod(final Class returnType, final String name, final Parameter... parms) { - return packageMethod(MetaClassFactory.get(returnType), name, parms); - } - - private MethodCommentBuilder genMethod(final Scope scope, - final MetaClass returnType, - final String name, - final DefParameters defParameters) { - - return new MethodBlockBuilderImpl(new MethodBuildCallback() { - @Override - public T callback(final BlockStatement statement, - final DefParameters parameters, - final DefModifiers modifiers, - final ThrowsDeclaration throwsDeclaration, - final List annotations, - final String comment) { - - final DefParameters dParameters; - - if (parameters != null) { - dParameters = parameters; - } - else { - dParameters = defParameters; - } - - final BuildMetaMethod buildMetaMethod = new BuildMetaMethod(classDefinition, statement, scope, - modifiers, name, returnType, dParameters, throwsDeclaration); - - if (annotations != null) { - buildMetaMethod.addAnnotations(annotations); - } - - buildMetaMethod.setMethodComment(comment); - classDefinition.addMethod(buildMetaMethod); - return (T) ClassBuilder.this; - } - }); - } - - @Override - public FieldBuildStart publicField(final String name, final MetaClass type) { - return genField(Scope.Public, name, type); - } - - @Override - public FieldBuildStart publicField(final String name, final Class type) { - return publicField(name, MetaClassFactory.get(type)); - } - - @Override - public FieldBuildStart privateField(final String name, final MetaClass type) { - return genField(Scope.Private, name, type); - } - - @Override - public FieldBuildStart privateField(final String name, final Class type) { - return privateField(name, MetaClassFactory.get(type)); - } - - @Override - public FieldBuildStart protectedField(final String name, final MetaClass type) { - return genField(Scope.Protected, name, type); - } - - @Override - public FieldBuildStart protectedField(final String name, final Class type) { - return protectedField(name, MetaClassFactory.get(type)); - } - - @Override - public FieldBuildStart packageField(final String name, final MetaClass type) { - return genField(Scope.Package, name, type); - } - - @Override - public FieldBuildStart packageField(final String name, final Class type) { - return packageField(name, MetaClassFactory.get(type)); - } - - private FieldBuildStart genField(final Scope scope, final String name, - final MetaClass type) { - return new FieldBuilder(new BuildCallback() { - @Override - public T callback(final Statement statement) { - final BuildMetaField buildMetaField - = new BuildMetaField(classDefinition, statement, scope, type, name); - - classDefinition.addField(buildMetaField); - return (T) ClassBuilder.this; - } - - @Override - public Context getParentContext() { - return classDefinition.getContext(); - } - }, scope, type, name); - } - - @Override - public BuildMetaClass getClassDefinition() { - return classDefinition; - } - - @Override - public String toJavaString() { - try { - return classDefinition.toJavaString(); - } - catch (Throwable t) { - GenUtil.throwIfUnhandled("error generating class: " + classDefinition.getFullyQualifiedName(), t); - return null; - } - } - - @Override - public ClassStructureBuilder declaresInnerClass(InnerClass ic) { - classDefinition.addInnerClass(ic); - return this; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/ClassBuilderAbstractMethodOption.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/ClassBuilderAbstractMethodOption.java deleted file mode 100644 index c44945accf5..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/ClassBuilderAbstractMethodOption.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.impl; - -import java.lang.annotation.Annotation; -import java.util.List; - -import org.jboss.errai.codegen.BlockStatement; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.DefModifiers; -import org.jboss.errai.codegen.DefParameters; -import org.jboss.errai.codegen.Parameter; -import org.jboss.errai.codegen.ThrowsDeclaration; -import org.jboss.errai.codegen.builder.ClassStructureBuilderAbstractMethodOption; -import org.jboss.errai.codegen.builder.MethodBuildCallback; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.meta.impl.build.BuildMetaMethod; - -/** - * @author Christian Sadilek - */ -public class ClassBuilderAbstractMethodOption extends ClassBuilder - implements ClassStructureBuilderAbstractMethodOption { - - @SuppressWarnings({ "rawtypes", "unchecked" }) - ClassBuilderAbstractMethodOption(ClassBuilder that, Context context) { - super(that, context); - } - - @Override - public MethodBuilderAbstractOption publicAbstractMethod( - MetaClass returnType, String name) { - return genMethod(Scope.Public, returnType, name, DefParameters.none()); - } - - @Override - public MethodBuilderAbstractOption publicAbstractMethod( - Class returnType, String name) { - return publicAbstractMethod(MetaClassFactory.get(returnType), name); - } - - @Override - public MethodBuilderAbstractOption publicAbstractMethod( - MetaClass returnType, String name, MetaClass... parms) { - return genMethod(Scope.Public, returnType, name, DefParameters.fromTypeArray(parms)); - } - - @Override - public MethodBuilderAbstractOption publicAbstractMethod( - Class returnType, String name, Class... parms) { - return publicAbstractMethod(MetaClassFactory.get(returnType), name, MetaClassFactory.fromClassArray(parms)); - } - - @Override - public MethodBuilderAbstractOption publicAbstractMethod( - MetaClass returnType, String name, Parameter... parms) { - return genMethod(Scope.Public, returnType, name, DefParameters.fromParameters(parms)); - } - - @Override - public MethodBuilderAbstractOption publicAbstractMethod( - Class returnType, String name, Parameter... parms) { - return publicAbstractMethod(MetaClassFactory.get(returnType), name, parms); - } - - @Override - public MethodBuilderAbstractOption protectedAbstractMethod( - MetaClass returnType, String name) { - return genMethod(Scope.Protected, returnType, name, DefParameters.none()); - } - - @Override - public MethodBuilderAbstractOption protectedAbstractMethod( - Class returnType, String name) { - return protectedAbstractMethod(MetaClassFactory.get(returnType), name); - } - - @Override - public MethodBuilderAbstractOption protectedAbstractMethod( - MetaClass returnType, String name, MetaClass... parms) { - return genMethod(Scope.Protected, returnType, name, DefParameters.fromTypeArray(parms)); - } - - @Override - public MethodBuilderAbstractOption protectedAbstractMethod( - Class returnType, String name, Class... parms) { - return protectedAbstractMethod(MetaClassFactory.get(returnType), name, MetaClassFactory.fromClassArray(parms)); - } - - @Override - public MethodBuilderAbstractOption protectedAbstractMethod( - MetaClass returnType, String name, Parameter... parms) { - return genMethod(Scope.Protected, returnType, name, DefParameters.fromParameters(parms)); - } - - @Override - public MethodBuilderAbstractOption protectedAbstractMethod( - Class returnType, String name, Parameter... parms) { - return protectedAbstractMethod(MetaClassFactory.get(returnType), name, parms); - } - - @Override - public MethodBuilderAbstractOption packageAbstractMethod( - MetaClass returnType, String name) { - return genMethod(Scope.Package, returnType, name, DefParameters.none()); - } - - @Override - public MethodBuilderAbstractOption packageAbstractMethod( - Class returnType, String name) { - return packageAbstractMethod(MetaClassFactory.get(returnType), name); - } - - @Override - public MethodBuilderAbstractOption packageAbstractMethod( - MetaClass returnType, String name, MetaClass... parms) { - return genMethod(Scope.Package, returnType, name, DefParameters.fromTypeArray(parms)); - } - - @Override - public MethodBuilderAbstractOption packageAbstractMethod( - Class returnType, String name, Class... parms) { - return packageAbstractMethod(MetaClassFactory.get(returnType), name, MetaClassFactory.fromClassArray(parms)); - } - - @Override - public MethodBuilderAbstractOption packageAbstractMethod( - MetaClass returnType, String name, Parameter... parms) { - return genMethod(Scope.Package, returnType, name, DefParameters.fromParameters(parms)); - } - - @Override - public MethodBuilderAbstractOption packageAbstractMethod( - Class returnType, String name, Parameter... parms) { - return packageAbstractMethod(MetaClassFactory.get(returnType), name, parms); - } - - private MethodBuilderAbstractOption genMethod(final Scope scope, - final MetaClass returnType, - final String name, - final DefParameters defParameters) { - - return new MethodBuilderAbstractOption( - new MethodBuildCallback() { - @Override - public ClassStructureBuilderAbstractMethodOption callback(final BlockStatement statement, - final DefParameters parameters, - final DefModifiers modifiers, - final ThrowsDeclaration throwsDeclaration, - final List annotations, - final String comment) { - - final BuildMetaMethod buildMetaMethod = new BuildMetaMethod(classDefinition, statement, scope, modifiers, name, - returnType, defParameters, throwsDeclaration); - - if (annotations != null) { - buildMetaMethod.addAnnotations(annotations); - } - buildMetaMethod.setMethodComment(comment); - - classDefinition.addMethod(buildMetaMethod); - return ClassBuilderAbstractMethodOption.this; - } - }); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/ConstructorBlockBuilderImpl.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/ConstructorBlockBuilderImpl.java deleted file mode 100644 index 06b443a9e12..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/ConstructorBlockBuilderImpl.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.impl; - -import org.jboss.errai.codegen.AbstractStatement; -import org.jboss.errai.codegen.CallParameters; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.StringStatement; -import org.jboss.errai.codegen.builder.BlockBuilder; -import org.jboss.errai.codegen.builder.BuildCallback; -import org.jboss.errai.codegen.builder.ClassStructureBuilder; -import org.jboss.errai.codegen.builder.ConstructorBlockBuilder; -import org.jboss.errai.codegen.util.GenUtil; - -/** - * @author Mike Brock - */ -public class ConstructorBlockBuilderImpl> extends BlockBuilderImpl implements ConstructorBlockBuilder { - public ConstructorBlockBuilderImpl(BuildCallback tBuildCallback) { - super(tBuildCallback); - } - - @Override - public BlockBuilder callSuper() { - append(new StringStatement("super()", null)); - return this; - } - - @Override - public BlockBuilder callSuper(final Object... parameters) { - append(new AbstractStatement() { - @Override - public String generate(Context context) { - return "super" + - CallParameters.fromStatements(GenUtil.generateCallParameters(context, parameters)).generate(context); - } - }); - - return this; - } - - @Override - public BlockBuilder callThis(final Object... parameters) { - append(new AbstractStatement() { - - String generatedCache; - - @Override - public String generate(Context context) { - if (generatedCache != null) return generatedCache; - return generatedCache = "this" + - CallParameters.fromStatements(GenUtil.generateCallParameters(context, parameters)).generate(context); - } - }); - - return this; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/ContextBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/ContextBuilder.java deleted file mode 100644 index bff2eb3c022..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/ContextBuilder.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.impl; - -import java.util.Collection; - -import javax.enterprise.util.TypeLiteral; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.Variable; -import org.jboss.errai.codegen.builder.Builder; -import org.jboss.errai.codegen.builder.VariableDeclarationInitializer; - -/** - * Builder for the {@link Context}. - * - * @author Christian Sadilek - */ -public class ContextBuilder implements Builder { - private final Context context; - - protected ContextBuilder(Context context) { - this.context = context; - } - - public static ContextBuilder create() { - return new ContextBuilder(Context.create()); - } - - public static ContextBuilder create(Context context) { - return new ContextBuilder(context); - } - - public ContextBuilder addVariable(Variable variable) { - context.addVariable(variable); - return this; - } - - public ContextBuilder addVariable(String name, Class type) { - context.addVariable(Variable.create(name, type)); - return this; - } - - public ContextBuilder addVariable(String name, TypeLiteral type) { - context.addVariable(Variable.create(name, type)); - return this; - } - - public ContextBuilder addVariable(String name, Object initialization) { - context.addVariable(Variable.create(name, initialization)); - return this; - } - - public ContextBuilder addVariable(String name, Class type, Object initialization) { - context.addVariable(Variable.create(name, type, initialization)); - return this; - } - - public ContextBuilder addVariable(String name, TypeLiteral type, Object initialization) { - context.addVariable(Variable.create(name, type, initialization)); - return this; - } - - public VariableDeclarationInitializer declareVariable(final Variable var) { - context.addVariable(var); - return new VariableDeclarationInitializer() { - - @Override - public ContextBuilder initializeWith(Object initialization) { - var.initialize(initialization); - return ContextBuilder.this; - } - - @Override - public ContextBuilder initializeWith(Statement initialization) { - var.initialize(initialization); - return ContextBuilder.this; - } - - @Override - public ContextBuilder finish() { - return ContextBuilder.this; - } - }; - } - - public VariableDeclarationInitializer declareVariable(String name) { - return declareVariable(Variable.create(name, (Class) null)); - } - - public VariableDeclarationInitializer declareVariable(String name, Class type) { - return declareVariable(Variable.create(name, type)); - } - - public VariableDeclarationInitializer declareVariable(String name, TypeLiteral type) { - return declareVariable(Variable.create(name, type)); - } - - @Override - public String toJavaString() { - final Collection vars = context.getDeclaredVariables(); - final StringBuilder buf = new StringBuilder(128); - vars.forEach(var -> buf.append(var.generate(context)).append(";\n")); - return buf.toString(); - } - - public Context getContext() { - return context; - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/ContextualStatementBuilderImpl.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/ContextualStatementBuilderImpl.java deleted file mode 100644 index 840b75ccb91..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/ContextualStatementBuilderImpl.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.impl; - -import org.jboss.errai.codegen.AssignmentOperator; -import org.jboss.errai.codegen.BooleanExpression; -import org.jboss.errai.codegen.BooleanOperator; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.builder.BlockBuilder; -import org.jboss.errai.codegen.builder.CaseBlockBuilder; -import org.jboss.errai.codegen.builder.ContextualStatementBuilder; -import org.jboss.errai.codegen.builder.ElseBlockBuilder; -import org.jboss.errai.codegen.builder.StatementEnd; -import org.jboss.errai.codegen.builder.VariableReferenceContextualStatementBuilder; -import org.jboss.errai.codegen.builder.WhileBuilder; -import org.jboss.errai.codegen.builder.callstack.AssignVariable; -import org.jboss.errai.codegen.builder.callstack.LoadField; -import org.jboss.errai.codegen.builder.callstack.MethodCall; -import org.jboss.errai.codegen.builder.callstack.ReturnValue; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaField; -import org.jboss.errai.codegen.meta.MetaMethod; - -/** - * Implementation of the {@link ContextualStatementBuilder}. - * - * @author Christian Sadilek - * @author Mike Brock - */ -public class ContextualStatementBuilderImpl extends AbstractStatementBuilder implements ContextualStatementBuilder, - VariableReferenceContextualStatementBuilder { - - protected ContextualStatementBuilderImpl(Context context, CallElementBuilder callElementBuilder) { - super(context, callElementBuilder); - } - - // Invocation - @Override - public ContextualStatementBuilder invoke(MetaMethod method, Object... parameters) { - return invoke(method.getName(), parameters); - } - - @Override - public ContextualStatementBuilder invoke(String methodName, Object... parameters) { - appendCallElement(new MethodCall(methodName, parameters)); - return this; - } - - @Override - public VariableReferenceContextualStatementBuilder loadField(MetaField field) { - appendCallElement(new LoadField(field.getName())); - return this; - } - - @Override - public VariableReferenceContextualStatementBuilder loadField(String fieldName) { - appendCallElement(new LoadField(fieldName)); - return this; - } - - // Looping - @Override - public BlockBuilder foreach(String loopVarName) { - return new LoopBuilderImpl(context, callElementBuilder).foreach(loopVarName); - } - - @Override - public BlockBuilder foreach(String loopVarName, Class loopVarType) { - return new LoopBuilderImpl(context, callElementBuilder).foreach(loopVarName, loopVarType); - } - - @Override - public BlockBuilder foreach(String loopVarName, MetaClass loopVarType) { - return new LoopBuilderImpl(context, callElementBuilder).foreach(loopVarName, loopVarType); - } - - @Override - public BlockBuilder foreachIfNotNull(String loopVarName) { - return new LoopBuilderImpl(context, callElementBuilder).foreachIfNotNull(loopVarName); - } - - @Override - public BlockBuilder foreachIfNotNull(String loopVarName, Class loopVarType) { - return new LoopBuilderImpl(context, callElementBuilder).foreachIfNotNull(loopVarName, loopVarType); - } - - @Override - public BlockBuilder foreachIfNotNull(String loopVarName, MetaClass loopVarType) { - return new LoopBuilderImpl(context, callElementBuilder).foreachIfNotNull(loopVarName, loopVarType); - } - - @Override - public BlockBuilder for_(Statement initializer, BooleanExpression condition) { - return new LoopBuilderImpl(context, callElementBuilder).for_(initializer, condition); - } - - @Override - public BlockBuilder for_(Statement initializer, BooleanExpression condition, Statement afterBlock) { - return new LoopBuilderImpl(context, callElementBuilder).for_(initializer, condition, afterBlock); - } - - @Override - public BlockBuilder do_() { - return new LoopBuilderImpl(context, callElementBuilder).do_(); - } - - @Override - public BlockBuilder while_() { - return new LoopBuilderImpl(context, callElementBuilder).while_(); - } - - @Override - public BlockBuilder while_(BooleanOperator op, Statement rhs) { - return new LoopBuilderImpl(context, callElementBuilder).while_(op, rhs); - } - - @Override - public BlockBuilder while_(BooleanOperator op, Object rhs) { - return new LoopBuilderImpl(context, callElementBuilder).while_(op, rhs); - } - - // If-Then-Else - @Override - public BlockBuilder if_() { - return new IfBlockBuilderImpl(context, callElementBuilder).if_(); - } - - @Override - public BlockBuilder if_(BooleanOperator op, Statement rhs) { - return new IfBlockBuilderImpl(context, callElementBuilder).if_(op, rhs); - } - - @Override - public BlockBuilder if_(BooleanOperator op, Object rhs) { - return new IfBlockBuilderImpl(context, callElementBuilder).if_(op, rhs); - } - - @Override - public BlockBuilder ifNot() { - return new IfBlockBuilderImpl(context, callElementBuilder).ifNot(); - } - - // Switch - @Override - public CaseBlockBuilder switch_() { - return new SwitchBlockBuilderImpl(context, callElementBuilder).switch_(); - } - - // Value return - @Override - public StatementEnd returnValue() { - appendCallElement(new ReturnValue()); - return this; - } - - // Assignments - @Override - public StatementEnd assignValue(Object statement) { - return assignValue(AssignmentOperator.Assignment, statement); - } - - @Override - public StatementEnd assignValue(AssignmentOperator operator, Object statement) { - appendCallElement(new AssignVariable(operator, statement)); - return this; - } - - @Override - public String toString() { - return "[Statement:" + callElementBuilder + "]"; - - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/DeclareAssignmentBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/DeclareAssignmentBuilder.java deleted file mode 100644 index cf814190260..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/DeclareAssignmentBuilder.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.impl; - -import org.jboss.errai.codegen.AssignmentOperator; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.VariableReference; -import org.jboss.errai.codegen.builder.callstack.LoadClassReference; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public class DeclareAssignmentBuilder extends AssignmentBuilder { - public DeclareAssignmentBuilder(final boolean isFinal, final VariableReference reference, final Statement statement) { - super(isFinal, AssignmentOperator.Assignment, reference, statement); - } - - @Override - public String generate(final Context context) { - final String type = LoadClassReference.getClassReference(reference.getType(), context, true); - if (statement != null) { - return (isFinal ? "final " : "") + type + " " + super.generate(context); - } - else { - return (isFinal ? "final " : "") + type + " " + reference.getName(); - } - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/ExpressionBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/ExpressionBuilder.java deleted file mode 100644 index 411aff45083..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/ExpressionBuilder.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.impl; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Expression; -import org.jboss.errai.codegen.Operator; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.literal.LiteralFactory; -import org.jboss.errai.codegen.util.GenUtil; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public abstract class ExpressionBuilder implements Statement, Expression { - protected Statement lhs; - protected String lhsExpr; - - protected Statement rhs; - protected String rhsExpr; - - protected T operator; - protected String operExpr; - - protected boolean qualifyingBrackets = true; - - public ExpressionBuilder() {} - - public ExpressionBuilder(Statement rhs, T operator) { - this.rhs = rhs; - this.operator = operator; - } - - public ExpressionBuilder(Statement lhs, Statement rhs, T operator) { - this(rhs, operator); - this.lhs = lhs; - } - - public ExpressionBuilder(Object lhs, Object rhs, T operator) { - this.lhs = (!(lhs instanceof Statement)) ? LiteralFactory.getLiteral(lhs) : (Statement) lhs; - this.rhs = (!(rhs instanceof Statement)) ? LiteralFactory.getLiteral(rhs) : (Statement) rhs; - this.operator = operator; - } - - public ExpressionBuilder(Object rhs, T operator) { - this.lhs = null; - this.rhs = (!(rhs instanceof Statement)) ? LiteralFactory.getLiteral(rhs) : (Statement) rhs; - this.operator = operator; - } - - @Override - public String generate(Context context) { - if (operator != null) { - if (lhs != null) - operator.assertCanBeApplied(GenUtil.generate(context, lhs).getType()); - if (rhs != null) - operator.assertCanBeApplied(GenUtil.generate(context, rhs).getType()); - } - - operExpr = ""; - rhsExpr = ""; - - if (lhsExpr == null && lhs != null) { - if (qualifyingBrackets && lhs instanceof ExpressionBuilder && this.operator != null) { - lhsExpr = "(" + lhs.generate(context) + ")"; - } - else { - lhsExpr = lhs.generate(context); - } - } - else if (lhs == null) { - lhsExpr = ""; - } - - if (this.operator != null) { - operExpr = " " + this.operator.getCanonicalString() + " "; - } - - if (rhs != null) { - if (qualifyingBrackets && rhs instanceof ExpressionBuilder) { - rhsExpr = "(" + rhs.generate(context) + ")"; - } - else { - rhsExpr = rhs.generate(context); - } - } - - return lhsExpr + operExpr + rhsExpr; - } - - @Override - public Statement getLhs() { - return lhs; - } - - @Override - public void setLhs(Statement lhs) { - this.lhs = lhs; - } - - @Override - public String getLhsExpr() { - return lhsExpr; - } - - @Override - public void setLhsExpr(String lhsExpr) { - this.lhsExpr = lhsExpr; - } - - @Override - public Statement getRhs() { - return rhs; - } - - @Override - public void setRhs(Statement rhs) { - this.rhs = rhs; - } - - @Override - public T getOperator() { - return operator; - } - - @Override - public void setOperator(T operator) { - this.operator = operator; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/FieldBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/FieldBuilder.java deleted file mode 100644 index c3b276eea67..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/FieldBuilder.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.impl; - -import java.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.DefModifiers; -import org.jboss.errai.codegen.Modifier; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.Variable; -import org.jboss.errai.codegen.builder.BuildCallback; -import org.jboss.errai.codegen.builder.FieldBuildInitializer; -import org.jboss.errai.codegen.builder.FieldBuildName; -import org.jboss.errai.codegen.builder.FieldBuildStart; -import org.jboss.errai.codegen.builder.FieldBuildType; -import org.jboss.errai.codegen.builder.Finishable; -import org.jboss.errai.codegen.builder.callstack.LoadClassReference; -import org.jboss.errai.codegen.literal.AnnotationLiteral; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; - -/** - * @author Mike Brock - */ -public class FieldBuilder implements FieldBuildStart, FieldBuildType, - FieldBuildName, FieldBuildInitializer { - - private final BuildCallback callback; - private final Scope scope; - private DefModifiers modifiers; - private MetaClass type; - private String name; - private Statement initializer; - private final List annotations = new ArrayList(); - - public FieldBuilder(BuildCallback callback, Scope scope, MetaClass type, String name) { - this.callback = callback; - this.scope = scope; - this.type = type; - this.name = name; - } - - @Override - public Finishable initializesWith(Statement statement) { - this.initializer = statement; - return this; - } - - @Override - public FieldBuildInitializer modifiers(Modifier... modifiers) { - this.modifiers = new DefModifiers(modifiers); - return this; - } - - @Override - public FieldBuildName typeOf(Class type) { - this.type = MetaClassFactory.get(type); - return this; - } - - @Override - public FieldBuildName typeOf(MetaClass type) { - this.type = type; - return this; - } - - @Override - public FieldBuildInitializer named(String name) { - this.name = name; - return this; - } - - @Override - public FieldBuildInitializer annotatedWith(Annotation... annotation) { - annotations.addAll(Arrays.asList(annotation)); - return this; - } - - @Override - public T finish() { - if (callback != null) { - return callback.callback(new Statement() { - - private String generatedCache; - - @Override - public String generate(Context context) { - callback.getParentContext().addVariable(Variable.create(name, type)); - - if (generatedCache != null) return generatedCache; - - final StringBuilder sbuf = new StringBuilder(); - - annotations.forEach(a -> sbuf.append(new AnnotationLiteral(a).getCanonicalString(context)).append(" ")); - - sbuf.append(scope.getCanonicalName()) - .append(scope == Scope.Package ? "" : " ") - .append(modifiers != null ? modifiers.toJavaString() + " " : "") - .append(LoadClassReference.getClassReference(type, context, type.getTypeParameters() != null)) - .append(" ").append(name); - - if (initializer != null) { - sbuf.append(" = ").append(initializer.generate(context)); - } - - return generatedCache = sbuf.append(";").toString(); - } - - @Override - public MetaClass getType() { - return type; - } - }); - } - return null; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/IfBlockBuilderImpl.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/IfBlockBuilderImpl.java deleted file mode 100644 index c9b4388646b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/IfBlockBuilderImpl.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.impl; - -import org.jboss.errai.codegen.BooleanExpression; -import org.jboss.errai.codegen.BooleanOperator; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.builder.BlockBuilder; -import org.jboss.errai.codegen.builder.BuildCallback; -import org.jboss.errai.codegen.builder.ContextualIfBlockBuilder; -import org.jboss.errai.codegen.builder.ElseBlockBuilder; -import org.jboss.errai.codegen.builder.IfBlockBuilder; -import org.jboss.errai.codegen.builder.StatementEnd; -import org.jboss.errai.codegen.builder.callstack.ConditionalBlockCallElement; -import org.jboss.errai.codegen.control.IfBlock; -import org.jboss.errai.codegen.literal.NullLiteral; -import org.jboss.errai.codegen.util.GenUtil; - -/** - * StatementBuilder to generate if blocks. - * - * @author Christian Sadilek - */ -public class IfBlockBuilderImpl extends AbstractStatementBuilder implements ContextualIfBlockBuilder, IfBlockBuilder, - ElseBlockBuilder { - - private IfBlock ifBlock; - - protected IfBlockBuilderImpl(Context context, CallElementBuilder callElementBuilder) { - super(context, callElementBuilder); - } - - protected IfBlockBuilderImpl(Context context, CallElementBuilder callElementBuilder, IfBlock ifBlock) { - super(context, callElementBuilder); - this.ifBlock = ifBlock; - } - - @Override - public BlockBuilder if_() { - return if_(new BooleanExpressionBuilder()); - } - - @Override - public BlockBuilder ifNot() { - return if_(new BooleanExpressionBuilder().negate()); - } - - @Override - public BlockBuilder if_(BooleanOperator op, Statement rhs) { - if (rhs == null) - rhs = NullLiteral.INSTANCE; - return if_(new BooleanExpressionBuilder(rhs, op)); - } - - @Override - public BlockBuilder if_(BooleanOperator op, Object rhs) { - final Statement rhsStatement = GenUtil.generate(context, rhs); - return if_(new BooleanExpressionBuilder(rhsStatement, op)); - } - - @Override - public BlockBuilder if_(final BooleanExpression condition) { - ifBlock = new IfBlock(condition); - appendCallElement(new ConditionalBlockCallElement(ifBlock)); - - return new BlockBuilderImpl(ifBlock.getBlock(), new BuildCallback() { - @Override - public ElseBlockBuilder callback(Statement statement) { - return IfBlockBuilderImpl.this; - } - - @Override - public Context getParentContext() { - return context; - } - }); - } - - @Override - public BlockBuilder else_() { - return new BlockBuilderImpl(ifBlock.getElseBlock(), new BuildCallback() { - @Override - public StatementEnd callback(Statement statement) { - return IfBlockBuilderImpl.this; - } - - @Override - public Context getParentContext() { - return context; - } - }); - } - - @Override - public BlockBuilder elseif_(Statement lhs) { - return elseif_(lhs, null, null); - } - - @Override - public BlockBuilder elseif_(Statement lhs, BooleanOperator op, Statement rhs) { - final IfBlock elseIfBlock = new IfBlock(new BooleanExpressionBuilder(lhs, rhs, op)); - ifBlock.setElseIfBlock(elseIfBlock); - return elseif_(elseIfBlock); - } - - @Override - public BlockBuilder elseif_(Statement lhs, BooleanOperator op, Object rhs) { - return elseif_(lhs, op, GenUtil.generate(context, rhs)); - } - - private BlockBuilder elseif_(final IfBlock elseIfBlock) { - return new BlockBuilderImpl(elseIfBlock.getBlock(), new BuildCallback() { - @Override - public ElseBlockBuilder callback(Statement statement) { - return new IfBlockBuilderImpl(context, callElementBuilder, elseIfBlock); - } - - @Override - public Context getParentContext() { - return context; - } - }); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/LoopBuilderImpl.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/LoopBuilderImpl.java deleted file mode 100644 index 1da3c672dbb..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/LoopBuilderImpl.java +++ /dev/null @@ -1,228 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.impl; - -import org.jboss.errai.codegen.BlockStatement; -import org.jboss.errai.codegen.BooleanExpression; -import org.jboss.errai.codegen.BooleanOperator; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.Variable; -import org.jboss.errai.codegen.builder.BlockBuilder; -import org.jboss.errai.codegen.builder.BuildCallback; -import org.jboss.errai.codegen.builder.ContextualLoopBuilder; -import org.jboss.errai.codegen.builder.LoopBuilder; -import org.jboss.errai.codegen.builder.StatementEnd; -import org.jboss.errai.codegen.builder.WhileBuilder; -import org.jboss.errai.codegen.builder.callstack.CallElement; -import org.jboss.errai.codegen.builder.callstack.ConditionalBlockCallElement; -import org.jboss.errai.codegen.builder.callstack.DeferredCallElement; -import org.jboss.errai.codegen.control.DoWhileLoop; -import org.jboss.errai.codegen.control.ForLoop; -import org.jboss.errai.codegen.control.ForeachLoop; -import org.jboss.errai.codegen.control.WhileLoop; -import org.jboss.errai.codegen.literal.NullLiteral; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.meta.MetaParameterizedType; -import org.jboss.errai.codegen.util.GenUtil; - -/** - * StatementBuilder to generate loops. - * - * @author Christian Sadilek - */ -public class LoopBuilderImpl extends AbstractStatementBuilder implements ContextualLoopBuilder, LoopBuilder { - - protected LoopBuilderImpl(Context context, CallElementBuilder callElementBuilder) { - super(context, callElementBuilder); - } - - // foreach loop - @Override - public BlockBuilder foreach(String loopVarName) { - return foreach(loopVarName, (MetaClass) null); - } - - @Override - public BlockBuilder foreach(String loopVarName, Class loopVarType) { - return foreach(loopVarName, MetaClassFactory.get(loopVarType)); - } - - @Override - public BlockBuilder foreach(final String loopVarName, final MetaClass loopVarType) { - final BlockStatement body = new BlockStatement(); - appendCallElement(foreachCallElement(body, loopVarName, loopVarType, false)); - return createLoopBody(body); - } - - private CallElement foreachCallElement(final BlockStatement body, final String loopVarName, final MetaClass loopVarType, final boolean nullSafe) { - return new DeferredCallElement((writer, context, statement) -> { - GenUtil.assertIsIterable(statement); - final Variable loopVar = createForEachLoopVar(statement, loopVarName, loopVarType, context); - final String collection = writer.getCallString(); - writer.reset(); - writer.append(new ForeachLoop(loopVar, collection, body, nullSafe).generate(Context.create(context))); - }); - } - - @Override - public BlockBuilder foreachIfNotNull(String loopVarName) { - return foreachIfNotNull(loopVarName, (MetaClass) null); - } - - @Override - public BlockBuilder foreachIfNotNull(String loopVarName, Class loopVarType) { - return foreachIfNotNull(loopVarName, MetaClassFactory.get(loopVarType)); - } - - @Override - public BlockBuilder foreachIfNotNull(String loopVarName, MetaClass loopVarType) { - final BlockStatement body = new BlockStatement(); - appendCallElement(foreachCallElement(body, loopVarName, loopVarType, true)); - return createLoopBody(body); - } - - // do while loop - @Override - public BlockBuilder do_() { - final BlockStatement body = new BlockStatement(); - - return new BlockBuilderImpl(body, new BuildCallback() { - @Override - public WhileBuilder callback(Statement statement) { - return new WhileBuilder() { - - @Override - public StatementEnd while_(final BooleanExpression condition) { - appendCallElement(new ConditionalBlockCallElement(new DoWhileLoop(condition, body))); - return LoopBuilderImpl.this; - } - - @Override - public StatementEnd while_() { - while_(new BooleanExpressionBuilder()); - return LoopBuilderImpl.this; - } - - @Override - public StatementEnd while_(BooleanOperator op, Statement rhs) { - while_(new BooleanExpressionBuilder(rhs, op)); - return LoopBuilderImpl.this; - } - - @Override - public StatementEnd while_(BooleanOperator op, Object rhs) { - return while_(op, GenUtil.generate(context, rhs)); - } - }; - } - - @Override - public Context getParentContext() { - return context; - } - }); - } - - // while loop - @Override - public BlockBuilder while_() { - return while_(new BooleanExpressionBuilder()); - } - - @Override - public BlockBuilder while_(BooleanOperator op, Object rhs) { - return while_(op, GenUtil.generate(context, rhs)); - } - - @Override - public BlockBuilder while_(BooleanOperator op, Statement rhs) { - if (rhs == null) - rhs = NullLiteral.INSTANCE; - return while_(new BooleanExpressionBuilder(rhs, op)); - } - - @Override - public BlockBuilder while_(final BooleanExpression condition) { - final BlockStatement body = new BlockStatement(); - appendCallElement(new ConditionalBlockCallElement(new WhileLoop(condition, body))); - return createLoopBody(body); - } - - // for loop - @Override - public BlockBuilder for_(BooleanExpression condition) { - return for_((Statement) null, condition); - } - - @Override - public BlockBuilder for_(Statement initializer, BooleanExpression condition) { - return for_(initializer, condition, null); - } - - @Override - public BlockBuilder for_(final Statement initializer, final BooleanExpression condition, - final Statement countingExpression) { - - final BlockStatement body = new BlockStatement(); - appendCallElement(new ConditionalBlockCallElement(new ForLoop(condition, body, initializer, countingExpression))); - return createLoopBody(body); - } - - private BlockBuilder createLoopBody(BlockStatement body) { - return new BlockBuilderImpl(body, new BuildCallback() { - @Override - public StatementEnd callback(Statement statement) { - return LoopBuilderImpl.this; - } - - @Override - public Context getParentContext() { - return context; - } - }); - } - - private Variable createForEachLoopVar(Statement collection, String loopVarName, MetaClass providedLoopVarType, Context context) { - // infer the loop variable type - MetaClass loopVarType = MetaClassFactory.get(Object.class); - final MetaParameterizedType parameterizedType = collection.getType().getParameterizedType(); - if (parameterizedType != null && parameterizedType.getTypeParameters().length != 0 && - parameterizedType.getTypeParameters()[0] instanceof MetaClass) { - loopVarType = (MetaClass) parameterizedType.getTypeParameters()[0]; - } - else if (collection.getType().getComponentType() != null) { - loopVarType = collection.getType().getComponentType(); - } - - // try to use the provided loop variable type if possible (assignable from the inferred type) - if (providedLoopVarType != null) { - GenUtil.assertAssignableTypes(context, loopVarType, providedLoopVarType); - loopVarType = providedLoopVarType; - } - - final Variable loopVar = Variable.create(loopVarName, loopVarType); - context.addVariable(loopVar); - return loopVar; - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/MethodBlockBuilderImpl.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/MethodBlockBuilderImpl.java deleted file mode 100644 index c51124827f5..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/MethodBlockBuilderImpl.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.impl; - -import java.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import javax.enterprise.util.TypeLiteral; - -import org.jboss.errai.codegen.DefModifiers; -import org.jboss.errai.codegen.DefParameters; -import org.jboss.errai.codegen.Modifier; -import org.jboss.errai.codegen.ThrowsDeclaration; -import org.jboss.errai.codegen.builder.BlockBuilder; -import org.jboss.errai.codegen.builder.MethodBlockBuilder; -import org.jboss.errai.codegen.builder.MethodBuildCallback; -import org.jboss.errai.codegen.builder.MethodCommentBuilder; -import org.jboss.errai.codegen.literal.LiteralFactory; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; - -/** - * @author Christian Sadilek - * @author Mike Brock - */ -public class MethodBlockBuilderImpl extends BlockBuilderImpl - implements MethodCommentBuilder { - - protected String methodComment; - protected ThrowsDeclaration throwsDeclaration = ThrowsDeclaration.none(); - protected final MethodBuildCallback callback; - protected DefParameters defParameters; - protected final DefModifiers modifiers = new DefModifiers(); - protected final List annotations = new ArrayList(); - - public MethodBlockBuilderImpl(final MethodBuildCallback callback) { - super(null); - this.callback = callback; - } - - @Override - public MethodBlockBuilder methodComment(final String comment) { - methodComment = comment; - return this; - } - - @Override - public MethodBlockBuilder annotatedWith(final Annotation... annotations) { - Arrays.stream(annotations).forEach(a -> this.annotations.add(a)); - return this; - } - - @Override - public MethodBlockBuilder throws_(final Class... exceptionTypes) { - throwsDeclaration = ThrowsDeclaration.of(exceptionTypes); - return this; - } - - @Override - public MethodBlockBuilder throws_(final MetaClass... exceptions) { - throwsDeclaration = ThrowsDeclaration.of(exceptions); - return this; - } - - - @Override - public MethodBlockBuilder modifiers(final Modifier... modifiers) { - for (final Modifier m : modifiers) { - switch (m) { - case Transient: - case Volatile: - throw new RuntimeException("illegal modifier for method: " + m); - - default: - this.modifiers.addModifiers(m); - } - } - - return this; - } - - @Override - public MethodBlockBuilder parameters(final DefParameters parms) { - defParameters = parms; - return this; - } - - @Override - public MethodBlockBuilder parameters(final Class... parms) { - defParameters = DefParameters.fromTypeArray(MetaClassFactory.fromClassArray(parms)) ; - return this; - } - - @Override - public MethodBlockBuilder parameters(final MetaClass... parms) { - defParameters = DefParameters.fromTypeArray(parms); - return this; - } - - @Override - public MethodBlockBuilder parameters(final Object... parms) { - final List p = new ArrayList(); - for (final Object o : parms) { - LiteralFactory.getLiteral(o); - - if (o instanceof MetaClass) { - p.add((MetaClass) o); - } - else if (o instanceof Class) { - p.add(MetaClassFactory.get((Class) o)); - } - else if (o instanceof TypeLiteral) { - p.add(MetaClassFactory.get((TypeLiteral) o)); - } - } - - defParameters = DefParameters.fromTypeArray(p.toArray(new MetaClass[p.size()])); - - return this; - } - - @Override - public BlockBuilder body() { - return this; - } - - @Override - public T finish() { - if (callback != null) { - return callback.callback(blockStatement, defParameters, modifiers, throwsDeclaration, annotations, methodComment); - } - return null; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/MethodBuilderAbstractOption.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/MethodBuilderAbstractOption.java deleted file mode 100644 index 1fa68b7ec8e..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/MethodBuilderAbstractOption.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.impl; - -import org.jboss.errai.codegen.DefModifiers; -import org.jboss.errai.codegen.Modifier; -import org.jboss.errai.codegen.ThrowsDeclaration; -import org.jboss.errai.codegen.builder.Finishable; -import org.jboss.errai.codegen.builder.MethodBuildCallback; -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Christian Sadilek - */ -public class MethodBuilderAbstractOption implements Finishable { - protected ThrowsDeclaration throwsDeclaration = ThrowsDeclaration.none(); - protected MethodBuildCallback callback; - - public MethodBuilderAbstractOption(final MethodBuildCallback callback) { - this.callback = callback; - } - - public T throws_(final Class... exceptionTypes) { - throwsDeclaration = ThrowsDeclaration.of(exceptionTypes); - return callback.callback(null, null, new DefModifiers(Modifier.Abstract), throwsDeclaration, null, null); - } - - public T throws_(final MetaClass... exceptions) { - throwsDeclaration = ThrowsDeclaration.of(exceptions); - return callback.callback(null, null, new DefModifiers(Modifier.Abstract), throwsDeclaration, null, null); - } - - @Override - public T finish() { - if (callback != null) { - return callback.callback(null, null, new DefModifiers(Modifier.Abstract), throwsDeclaration, null, null); - } - return null; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/ObjectBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/ObjectBuilder.java deleted file mode 100644 index e4869e902f3..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/ObjectBuilder.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.impl; - -import java.util.Arrays; - -import javax.enterprise.util.TypeLiteral; - -import org.jboss.errai.codegen.CallParameters; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.Variable; -import org.jboss.errai.codegen.builder.AnonymousClassStructureBuilder; -import org.jboss.errai.codegen.builder.BuildCallback; -import org.jboss.errai.codegen.builder.StatementEnd; -import org.jboss.errai.codegen.builder.callstack.DeferredCallElement; -import org.jboss.errai.codegen.builder.callstack.LoadClassReference; -import org.jboss.errai.codegen.exception.InvalidTypeException; -import org.jboss.errai.codegen.exception.UndefinedConstructorException; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.util.GenUtil; - -import static org.jboss.errai.codegen.CallParameters.fromStatements; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public class ObjectBuilder extends AbstractStatementBuilder { - - private final MetaClass type; - private Object[] parameters; - - private Statement extendsBlock; - - private final RuntimeException blame = new RuntimeException("Problem was caused by this call"); - - ObjectBuilder(final MetaClass type, final Context context, final CallElementBuilder callElementBuilder) { - super(context, callElementBuilder); - - if (context != null) { - context.attachClass(type); - - Arrays.stream(type.getDeclaredFields()). - forEach(f -> context.addVariable(Variable.create(f.getName(), f.getType()))); - } - - this.type = type; - } - - ObjectBuilder(final MetaClass type, final Context context) { - this(type, context, new CallElementBuilder()); - } - - ObjectBuilder(final MetaClass type) { - this(type, Context.create(), new CallElementBuilder()); - } - - public static ObjectBuilder newInstanceOf(final MetaClass type) { - return new ObjectBuilder(type); - } - - public static ObjectBuilder newInstanceOf(final Class type) { - return newInstanceOf(MetaClassFactory.get(type)); - } - - public static ObjectBuilder newInstanceOf(final TypeLiteral type) { - return newInstanceOf(MetaClassFactory.get(type)); - } - - public static ObjectBuilder newInstanceOf(final MetaClass type, final Context context) { - return new ObjectBuilder(type, context); - } - - public static ObjectBuilder newInstanceOf(final Class type, final Context context) { - return newInstanceOf(MetaClassFactory.get(type), context); - } - - public static ObjectBuilder newInstanceOf(final TypeLiteral type, final Context context) { - return newInstanceOf(MetaClassFactory.get(type), context); - } - - public static ObjectBuilder newInstanceOf(final MetaClass type, final Context context, final CallElementBuilder callElementBuilder) { - return new ObjectBuilder(type, context, callElementBuilder); - } - - public static ObjectBuilder newInstanceOf(final Class type, final Context context, final CallElementBuilder callElementBuilder) { - return newInstanceOf(MetaClassFactory.get(type), context, callElementBuilder); - } - - public static ObjectBuilder newInstanceOf(final TypeLiteral type, final Context context, final CallElementBuilder callElementBuilder) { - return newInstanceOf(MetaClassFactory.get(type), context, callElementBuilder); - } - - public StatementEnd withParameters(final Object... parameters) { - this.parameters = parameters; - return this; - } - - public AnonymousClassStructureBuilder extend() { - return new AnonymousClassStructureBuilderImpl(type, new BuildCallback() { - @Override - public ObjectBuilder callback(final Statement statement) { - extendsBlock = statement; - return ObjectBuilder.this; - } - - @Override - public Context getParentContext() { - return context; - } - }); - } - - public AnonymousClassStructureBuilder extend(final Object... parameters) { - this.parameters = parameters; - return extend(); - } - - @Override - public MetaClass getType() { - return type; - } - - @Override - public String generate(final Context context) { - - if (!generated) { - appendCallElement(new DeferredCallElement((writer, context1, statement) -> { - if (extendsBlock == null && (type.isAbstract() || type.isInterface() || type.isPrimitive())) - throw new InvalidTypeException("Cannot instantiate type:" + type, blame); - - writer.reset(); - - final CallParameters callParameters = (parameters != null) ? - fromStatements(GenUtil.generateCallParameters(context1, parameters)) : CallParameters.none(); - - if (!type.isInterface() && type.getBestMatchingConstructor(callParameters.getParameterTypes()) == null) { - if (context1.isPermissiveMode()) { - // fall-through - } - else { - throw new UndefinedConstructorException(type, blame, callParameters.getParameterTypes()); - } - } - - final StringBuilder buf = new StringBuilder(); - buf.append("new ").append(LoadClassReference.getClassReference(type, context1, true)); - if (callParameters != null) { - buf.append(callParameters.generate(Context.create(context1))); - } - if (extendsBlock != null) { - Arrays.stream(type.getDeclaredFields()) - .forEach(field -> context1.addVariable(Variable.create(field.getName(), field.getType()))); - buf.append(" {\n").append(extendsBlock.generate(context1)).append("\n}\n"); - } - writer.append(buf.toString()); - })); - } - - try { - return super.generate(context); - } - catch (final Throwable t) { - GenUtil.throwIfUnhandled("while instantiating class: " + type.getFullyQualifiedName(), t); - return null; - } - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/Scope.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/Scope.java deleted file mode 100644 index 32b210b3327..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/Scope.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.impl; - -/** - * @author Mike Brock - */ -public enum Scope { - Public { - @Override - public String getCanonicalName() { - return "public"; - } - }, - Private { - @Override - public String getCanonicalName() { - return "private"; - } - }, - Protected { - @Override - public String getCanonicalName() { - return "protected"; - } - }, - Package { - @Override - public String getCanonicalName() { - return ""; - } - }; - - public abstract String getCanonicalName(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/StatementBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/StatementBuilder.java deleted file mode 100644 index fa505759af2..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/StatementBuilder.java +++ /dev/null @@ -1,438 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.impl; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.enterprise.util.TypeLiteral; - -import org.jboss.errai.codegen.BooleanExpression; -import org.jboss.errai.codegen.Cast; -import org.jboss.errai.codegen.Comment; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.Variable; -import org.jboss.errai.codegen.builder.ArrayInitializationBuilder; -import org.jboss.errai.codegen.builder.BlockBuilder; -import org.jboss.errai.codegen.builder.CaseBlockBuilder; -import org.jboss.errai.codegen.builder.CatchBlockBuilder; -import org.jboss.errai.codegen.builder.ContextualStatementBuilder; -import org.jboss.errai.codegen.builder.ElseBlockBuilder; -import org.jboss.errai.codegen.builder.StatementBegin; -import org.jboss.errai.codegen.builder.StatementEnd; -import org.jboss.errai.codegen.builder.VariableDeclarationInitializer; -import org.jboss.errai.codegen.builder.VariableDeclarationNamed; -import org.jboss.errai.codegen.builder.VariableDeclarationStart; -import org.jboss.errai.codegen.builder.VariableReferenceContextualStatementBuilder; -import org.jboss.errai.codegen.builder.WhileBuilder; -import org.jboss.errai.codegen.builder.callstack.BranchCallElement; -import org.jboss.errai.codegen.builder.callstack.DeclareVariable; -import org.jboss.errai.codegen.builder.callstack.DefineLabel; -import org.jboss.errai.codegen.builder.callstack.DynamicLoad; -import org.jboss.errai.codegen.builder.callstack.LoadClassReference; -import org.jboss.errai.codegen.builder.callstack.LoadField; -import org.jboss.errai.codegen.builder.callstack.LoadLiteral; -import org.jboss.errai.codegen.builder.callstack.LoadNested; -import org.jboss.errai.codegen.builder.callstack.LoadVariable; -import org.jboss.errai.codegen.builder.callstack.MethodCall; -import org.jboss.errai.codegen.builder.callstack.ResetCallElement; -import org.jboss.errai.codegen.builder.callstack.ThrowException; -import org.jboss.errai.codegen.control.branch.BreakStatement; -import org.jboss.errai.codegen.control.branch.ContinueStatement; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; - -/** - * The root of our fluent StatementBuilder API. - * - * @author Christian Sadilek - * @author Mike Brock - */ -public class StatementBuilder extends AbstractStatementBuilder implements StatementBegin { - - private static final Pattern THIS_OR_SUPPER_PATTERN = Pattern.compile("(this|super)"); - private static final Pattern THIS_PATTERN = Pattern.compile("(this\\.)(.)*"); - - public StatementBuilder(final Context context) { - super(context); - - if (context != null) { - context.getDeclaredVariables().stream() - .filter(v -> !THIS_OR_SUPPER_PATTERN.matcher(v.getName()).matches()) - .forEach(v -> appendCallElement(new DeclareVariable(v))); - } - appendCallElement(new ResetCallElement()); - } - - public static StatementBegin create() { - return new StatementBuilder(null); - } - - public static StatementBegin create(final Context context) { - return new StatementBuilder(context); - } - - @Override - public VariableDeclarationStart declareVariable(final Class type) { - return declareVariable(MetaClassFactory.get(type)); - } - - @Override - public VariableDeclarationStart declareVariable(final MetaClass type) { - return new VariableDeclarationStart() { - boolean isFinal; - String name; - Object initialization; - - @Override - public VariableDeclarationNamed asFinal() { - isFinal = true; - return this; - } - - @Override - public VariableDeclarationInitializer named(final String name) { - this.name = name; - return this; - } - - @Override - public StatementBuilder initializeWith(final Object initialization) { - this.initialization = initialization; - return finish(); - } - - @Override - public StatementBuilder initializeWith(final Statement initialization) { - this.initialization = initialization; - return finish(); - } - - @Override - public StatementBuilder finish() { - if (initialization == null) { - declareVariable(isFinal ? Variable.createFinal(name, type) : Variable.create(name, type)); - } - else { - declareVariable(isFinal ? Variable.createFinal(name, type, initialization) : Variable.create(name, type, - initialization)); - } - return StatementBuilder.this; - } - }; - } - - @Override - public StatementBuilder declareVariable(final String name, final Class type) { - return declareVariable(Variable.create(name, type)); - } - - @Override - public StatementBuilder declareVariable(final String name, final TypeLiteral type) { - return declareVariable(Variable.create(name, type)); - } - - @Override - public StatementBuilder declareVariable(final String name, final Object initialization) { - return declareVariable(Variable.create(name, initialization)); - } - - @Override - public StatementBuilder declareVariable(final String name, final MetaClass type, final Object initialization) { - return declareVariable(Variable.create(name, type, initialization)); - } - - @Override - public StatementBuilder declareVariable(final String name, final Class type, final Object initialization) { - return declareVariable(Variable.create(name, type, initialization)); - } - - @Override - public StatementBuilder declareVariable(final String name, final TypeLiteral type, final Object initialization) { - return declareVariable(Variable.create(name, type, initialization)); - } - - @Override - public StatementBuilder declareFinalVariable(final String name, final Class type) { - return declareVariable(Variable.createFinal(name, type)); - } - - @Override - public StatementBuilder declareFinalVariable(final String name, final TypeLiteral type) { - return declareVariable(Variable.createFinal(name, type)); - } - - @Override - public StatementBuilder declareFinalVariable(final String name, final MetaClass type, final Object initialization) { - return declareVariable(Variable.createFinal(name, type, initialization)); - } - - @Override - public StatementBuilder declareFinalVariable(final String name, final Class type, final Object initialization) { - return declareVariable(Variable.createFinal(name, type, initialization)); - } - - @Override - public StatementBuilder declareFinalVariable(final String name, final TypeLiteral type, final Object initialization) { - return declareVariable(Variable.createFinal(name, type, initialization)); - } - - private StatementBuilder declareVariable(final Variable v) { - appendCallElement(new DeclareVariable(v)); - return this; - } - - @Override - public VariableReferenceContextualStatementBuilder loadVariable(final String name, final Object... indexes) { - final Matcher m = THIS_PATTERN.matcher(name); - if (m.matches()) { - return loadClassMember(name.replaceFirst("(this\\.)", ""), indexes); - } - appendCallElement(new LoadVariable(name, indexes)); - return new ContextualStatementBuilderImpl(context, callElementBuilder); - } - - @Override - public VariableReferenceContextualStatementBuilder loadClassMember(final String name, final Object... indexes) { - appendCallElement(new LoadVariable(name, true, indexes)); - return new ContextualStatementBuilderImpl(context, callElementBuilder); - } - - @Override - public ContextualStatementBuilder loadLiteral(final Object o) { - appendCallElement(new LoadLiteral(o)); - return new ContextualStatementBuilderImpl(context, callElementBuilder); - } - - @Override - public ContextualStatementBuilder load(final Object o) { - appendCallElement(new DynamicLoad(o)); - return new ContextualStatementBuilderImpl(context, callElementBuilder); - } - - @Override - public ContextualStatementBuilder loadClassReference(final Object o) { - final MetaClass c; - if (o instanceof MetaClass) { - c = (MetaClass) o; - } - else if (o instanceof Class) { - c = MetaClassFactory.get((Class) o); - } - else { - throw new RuntimeException("unknown class reference type: " + (o == null ? "null" : o.getClass().getName())); - } - appendCallElement(new LoadClassReference(c)); - return new ContextualStatementBuilderImpl(context, callElementBuilder); - } - - @Override - public ContextualStatementBuilder invokeStatic(final MetaClass clazz, final String methodName, final Object... parameters) { - appendCallElement(new LoadClassReference(clazz)); - appendCallElement(new MethodCall(methodName, parameters, true)); - return new ContextualStatementBuilderImpl(context, callElementBuilder); - } - - @Override - public ContextualStatementBuilder invokeStatic(final Class clazz, final String methodName, final Object... parameters) { - return invokeStatic(MetaClassFactory.get(clazz), methodName, parameters); - } - - @Override - public ContextualStatementBuilder loadStatic(final Class clazz, final String fieldName) { - return loadStatic(MetaClassFactory.get(clazz), fieldName); - } - - @Override - public ContextualStatementBuilder loadStatic(final MetaClass clazz, final String fieldName) { - appendCallElement(new LoadClassReference(clazz)); - appendCallElement(new LoadField(fieldName)); - return new ContextualStatementBuilderImpl(context, callElementBuilder); - } - - @Override - public ContextualStatementBuilder nestedCall(final Statement statement) { - appendCallElement(new LoadNested(statement)); - return new ContextualStatementBuilderImpl(context, callElementBuilder); - } - - @Override - public ObjectBuilder newObject(final Class type) { - return ObjectBuilder.newInstanceOf(type, context, callElementBuilder); - } - - @Override - public ObjectBuilder newObject(final MetaClass type) { - return ObjectBuilder.newInstanceOf(type, context, callElementBuilder); - } - - @Override - public ObjectBuilder newObject(final TypeLiteral type) { - return ObjectBuilder.newInstanceOf(type, context, callElementBuilder); - } - - @Override - public Statement newObject(final Class type, final Object... parameters) { - return ObjectBuilder.newInstanceOf(type, context, callElementBuilder) - .withParameters(parameters); - } - - @Override - public Statement newObject(final MetaClass type, final Object... parameters) { - return ObjectBuilder.newInstanceOf(type, context, callElementBuilder) - .withParameters(parameters); - } - - @Override - public Statement newObject(final TypeLiteral type, final Object... parameters) { - return ObjectBuilder.newInstanceOf(type, context, callElementBuilder) - .withParameters(parameters); - } - - @Override - public ArrayInitializationBuilder newArray(final MetaClass componentType, final Object... dimensions) { - return new ArrayBuilderImpl(context, callElementBuilder).newArray(componentType, dimensions); - } - - @Override - public ArrayInitializationBuilder newArray(final Class componentType, final Object... dimensions) { - return new ArrayBuilderImpl(context, callElementBuilder).newArray(componentType, dimensions); - } - - @Override - public BlockBuilder do_() { - return new LoopBuilderImpl(context, callElementBuilder).do_(); - } - - @Override - public BlockBuilder if_(final BooleanExpression stmt) { - return new IfBlockBuilderImpl(context, callElementBuilder).if_(stmt); - } - - @Override - public BlockBuilder while_(final BooleanExpression stmt) { - return new LoopBuilderImpl(context, callElementBuilder).while_(stmt); - } - - @Override - public BlockBuilder for_(final BooleanExpression condition) { - return new LoopBuilderImpl(context, callElementBuilder).for_(condition); - } - - @Override - public BlockBuilder for_(final Statement initializer, final BooleanExpression condition) { - return new LoopBuilderImpl(context, callElementBuilder).for_(initializer, condition); - } - - @Override - public BlockBuilder for_(final Statement initializer, final BooleanExpression condition, - final Statement countingExpression) { - return new LoopBuilderImpl(context, callElementBuilder).for_(initializer, condition, countingExpression); - } - - @Override - public CaseBlockBuilder switch_(final Statement statement) { - return new SwitchBlockBuilderImpl(context, callElementBuilder).switch_(statement); - } - - @Override - public BlockBuilder try_() { - return new TryBlockBuilderImpl(context, callElementBuilder).try_(); - } - - @Override - public StatementEnd throw_(final Class throwableType, final Object... parameters) { - appendCallElement(new ThrowException(throwableType, parameters)); - return this; - } - - @Override - public StatementEnd throw_(final String exceptionVarName) { - appendCallElement(new ThrowException(exceptionVarName)); - return this; - } - - @Override - public StatementEnd label(final String label) { - appendCallElement(new DefineLabel(label)); - return this; - } - - @Override - public StatementEnd break_() { - appendCallElement(new BranchCallElement(new BreakStatement())); - return this; - } - - @Override - public StatementEnd break_(final String label) { - appendCallElement(new BranchCallElement(new BreakStatement(label))); - return this; - } - - @Override - public StatementEnd continue_() { - appendCallElement(new BranchCallElement(new ContinueStatement())); - return this; - } - - @Override - public StatementEnd continue_(final String label) { - appendCallElement(new BranchCallElement(new ContinueStatement(label))); - return this; - } - - @Override - public StatementEnd returnVoid() { - return new StatementEnd() { - @Override - public String toJavaString() { - return "return"; - } - - @Override - public String generate(final Context context) { - return toJavaString(); - } - - @Override - public MetaClass getType() { - return MetaClassFactory.get(void.class); - } - }; - } - - @Override - public ContextualStatementBuilder castTo(final Class type, final Statement statement) { - return nestedCall(Cast.to(type, statement)); - } - - @Override - public ContextualStatementBuilder castTo(final MetaClass type, final Statement statement) { - return nestedCall(Cast.to(type, statement)); - } - - @Override - public Statement codeComment(final String comment) { - return new Comment(comment); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/StringExpressionBuilder.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/StringExpressionBuilder.java deleted file mode 100644 index 7e67e07e91b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/StringExpressionBuilder.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.impl; - -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.StringExpression; -import org.jboss.errai.codegen.StringOperator; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; - -/** - * @author Slava Pankov - */ -public class StringExpressionBuilder extends ExpressionBuilder implements StringExpression { - - public StringExpressionBuilder() {} - - public StringExpressionBuilder(Statement rhs, StringOperator operator) { - super(rhs, operator); - } - - public StringExpressionBuilder(Object rhs, StringOperator operator) { - super(rhs, operator); - } - - public StringExpressionBuilder(Statement lhs, Statement rhs, StringOperator operator) { - super(lhs, rhs, operator); - } - - public StringExpressionBuilder(Object lhs, Object rhs, StringOperator operator) { - super(lhs, rhs, operator); - } - - public static StringExpression create(Statement lhs) { - return new StringExpressionBuilder(lhs, null, null); - } - - public static StringExpression create(StringOperator operator, Object rhs) { - return new StringExpressionBuilder(rhs, operator); - } - - public static StringExpression create(Object lhs, StringOperator operator, Object rhs) { - return new StringExpressionBuilder(lhs, rhs, operator); - } - - @Override - public MetaClass getType() { - Class lhsType = null; - if (lhs != null) { - lhsType = lhs.getType().asUnboxed().asClass(); - } - Class rhsType = null; - if (rhs != null) { - rhsType = rhs.getType().asUnboxed().asClass(); - } - return MetaClassFactory.get(promote(lhsType, rhsType)); - } - - private Class promote(Class lhs, Class rhs) { - return String.class; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/SwitchBlockBuilderImpl.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/SwitchBlockBuilderImpl.java deleted file mode 100644 index 20e98aa1a68..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/SwitchBlockBuilderImpl.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.impl; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.builder.BlockBuilder; -import org.jboss.errai.codegen.builder.BuildCallback; -import org.jboss.errai.codegen.builder.CaseBlockBuilder; -import org.jboss.errai.codegen.builder.ContextualSwitchBlockBuilder; -import org.jboss.errai.codegen.builder.StatementEnd; -import org.jboss.errai.codegen.builder.SwitchBlockBuilder; -import org.jboss.errai.codegen.builder.callstack.DeferredCallElement; -import org.jboss.errai.codegen.control.SwitchBlock; -import org.jboss.errai.codegen.literal.ByteValue; -import org.jboss.errai.codegen.literal.CharValue; -import org.jboss.errai.codegen.literal.IntValue; -import org.jboss.errai.codegen.literal.LiteralFactory; -import org.jboss.errai.codegen.literal.LiteralValue; -import org.jboss.errai.codegen.literal.ShortValue; -import org.jboss.errai.codegen.literal.StringLiteral; - -/** - * StatementBuilder to generate switch blocks. - * - * @author Christian Sadilek - */ -public class SwitchBlockBuilderImpl extends AbstractStatementBuilder implements SwitchBlockBuilder, - ContextualSwitchBlockBuilder, CaseBlockBuilder { - - private SwitchBlock switchBlock; - - protected SwitchBlockBuilderImpl(Context context, CallElementBuilder callElementBuilder) { - super(context, callElementBuilder); - } - - @Override - public CaseBlockBuilder switch_() { - return switch_(new SwitchBlock()); - } - - @Override - public CaseBlockBuilder switch_(Statement statement) { - return switch_(new SwitchBlock(statement)); - } - - private CaseBlockBuilder switch_(final SwitchBlock switchBlock) { - this.switchBlock = switchBlock; - appendCallElement(new DeferredCallElement((writer, context, statement) -> { - if (statement != null) { - switchBlock.setSwitchExpr(statement); - switchBlock.setSwitchExpr(writer.getCallString()); - } - writer.reset(); - writer.append(switchBlock.generate(Context.create(context))); - })); - - return this; - } - - @Override - public BlockBuilder case_(IntValue value) { - switchBlock.addCase(value); - return caseBlock(value); - } - - @Override - public BlockBuilder case_(int value) { - final IntValue val = (IntValue) LiteralFactory.getLiteral(value); - return case_(val); - } - - @Override - public BlockBuilder case_(CharValue value) { - switchBlock.addCase(value); - return caseBlock(value); - } - - @Override - public BlockBuilder case_(char value) { - final CharValue val = (CharValue) LiteralFactory.getLiteral(value); - return case_(val); - } - - @Override - public BlockBuilder case_(String value) { - StringLiteral val = (StringLiteral) LiteralFactory.getLiteral(value); - switchBlock.addCase(val); - return caseBlock(val); - } - - @Override - public BlockBuilder case_(ByteValue value) { - switchBlock.addCase(value); - return caseBlock(value); - } - - @Override - public BlockBuilder case_(byte value) { - final ByteValue val = (ByteValue) LiteralFactory.getLiteral(value); - return case_(val); - } - - @Override - public BlockBuilder case_(ShortValue value) { - switchBlock.addCase(value); - return caseBlock(value); - } - - @Override - public BlockBuilder case_(short value) { - final ShortValue val = (ShortValue) LiteralFactory.getLiteral(value); - return case_(val); - } - - @Override - public BlockBuilder case_(LiteralValue> value) { - switchBlock.addCase(value); - return caseBlock(value); - } - - @Override - public BlockBuilder case_(Enum value) { - final LiteralValue> val = (LiteralValue>) LiteralFactory.getLiteral(value); - return case_(val); - } - - private BlockBuilder caseBlock(LiteralValue value) { - return new BlockBuilderImpl(switchBlock.getCaseBlock(value), - new BuildCallback() { - - @Override - public CaseBlockBuilder callback(Statement statement) { - return SwitchBlockBuilderImpl.this; - } - - @Override - public Context getParentContext() { - return context; - } - }); - } - - @Override - public BlockBuilder default_() { - return new BlockBuilderImpl(switchBlock.getDefaultBlock(), - new BuildCallback() { - - @Override - public StatementEnd callback(Statement statement) { - return SwitchBlockBuilderImpl.this; - } - - @Override - public Context getParentContext() { - return context; - } - }); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/TryBlockBuilderImpl.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/TryBlockBuilderImpl.java deleted file mode 100644 index a29ee04cde9..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/builder/impl/TryBlockBuilderImpl.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.builder.impl; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.Variable; -import org.jboss.errai.codegen.builder.BlockBuilder; -import org.jboss.errai.codegen.builder.BuildCallback; -import org.jboss.errai.codegen.builder.CatchBlockBuilder; -import org.jboss.errai.codegen.builder.StatementEnd; -import org.jboss.errai.codegen.builder.TryBlockBuilder; -import org.jboss.errai.codegen.builder.callstack.DeferredCallElement; -import org.jboss.errai.codegen.control.TryBlock; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; - -/** - * StatementBuilder to generate try/catch/finally blocks. - * - * @author Christian Sadilek - */ -public class TryBlockBuilderImpl extends AbstractStatementBuilder implements TryBlockBuilder, CatchBlockBuilder { - private TryBlock tryBlock; - - protected TryBlockBuilderImpl(Context context, CallElementBuilder callElementBuilder) { - super(context, callElementBuilder); - } - - @Override - public BlockBuilder try_() { - tryBlock = new TryBlock(); - - appendCallElement(new DeferredCallElement((writer, context, statement) -> { - writer.reset(); - writer.append(tryBlock.generate(Context.create(context))); - })); - - return new BlockBuilderImpl(tryBlock.getBlock(), new BuildCallback() { - @Override - public CatchBlockBuilder callback(Statement statement) { - return TryBlockBuilderImpl.this; - } - - @Override - public Context getParentContext() { - return context; - } - }); - } - - @Override - public BlockBuilder catch_(Class exceptionType, String variableName) { - return catch_(MetaClassFactory.get(exceptionType), variableName); - } - - @Override - public BlockBuilder catch_(MetaClass exceptionType, String variableName) { - final Variable exceptionVar = Variable.create(variableName, exceptionType); - tryBlock.addCatchBlock(exceptionVar); - - return new BlockBuilderImpl(tryBlock.getCatchBlock(exceptionVar), - new BuildCallback() { - @Override - public CatchBlockBuilder callback(Statement statement) { - return TryBlockBuilderImpl.this; - } - - @Override - public Context getParentContext() { - return context; - } - }); - } - - @Override - public BlockBuilder finally_() { - return new BlockBuilderImpl(tryBlock.getFinallyBlock(), new BuildCallback() { - @Override - public StatementEnd callback(Statement statement) { - return TryBlockBuilderImpl.this; - } - - @Override - public Context getParentContext() { - return context; - } - }); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/AbstractConditionalBlock.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/AbstractConditionalBlock.java deleted file mode 100644 index 082190ebb11..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/AbstractConditionalBlock.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.control; - -import org.jboss.errai.codegen.AbstractStatement; -import org.jboss.errai.codegen.BlockStatement; -import org.jboss.errai.codegen.BooleanExpression; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public abstract class AbstractConditionalBlock extends AbstractStatement { - private BooleanExpression condition; - private BlockStatement block; - - protected AbstractConditionalBlock(BooleanExpression condition) { - this.condition = condition; - this.block = new BlockStatement(); - } - - protected AbstractConditionalBlock(BooleanExpression condition, BlockStatement block) { - this.condition = condition; - this.block = block; - } - - public BooleanExpression getCondition() { - return condition; - } - - public BlockStatement getBlock() { - return block; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/DoWhileLoop.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/DoWhileLoop.java deleted file mode 100644 index 8fd897367a1..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/DoWhileLoop.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.control; - -import org.jboss.errai.codegen.BlockStatement; -import org.jboss.errai.codegen.BooleanExpression; -import org.jboss.errai.codegen.Context; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public class DoWhileLoop extends AbstractConditionalBlock { - public DoWhileLoop(BooleanExpression condition, BlockStatement block) { - super(condition, block); - } - - @Override - public String generate(Context context) { - final StringBuilder builder = new StringBuilder("do {\n"); - - if (getBlock() != null) { - builder.append(getBlock().generate(context)); - } - - builder.append("\n} while (").append(getCondition().generate(context)).append(");\n"); - - return builder.toString(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/ForLoop.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/ForLoop.java deleted file mode 100644 index a968a24171b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/ForLoop.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.control; - -import org.jboss.errai.codegen.BlockStatement; -import org.jboss.errai.codegen.BooleanExpression; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.Variable; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public class ForLoop extends AbstractConditionalBlock { - private Statement initializer; - private Statement afterBlock; - - public ForLoop(BooleanExpression condition, BlockStatement block) { - super(condition, block); - } - - public ForLoop(BooleanExpression condition, BlockStatement block, Statement initializer, Statement afterBlock) { - super(condition, block); - this.initializer = initializer; - this.afterBlock = afterBlock; - } - - String generatedCache; - @Override - public String generate(Context context) { - if (generatedCache != null) return generatedCache; - final StringBuilder builder = new StringBuilder("for ("); - - if (initializer != null) { - builder.append(initializer.generate(context)); - if (initializer instanceof Variable) { - context.addVariable((Variable) initializer); - } - } - - if (!builder.toString().endsWith(";")) - builder.append(";"); - - builder.append(" ").append(getCondition().generate(context)).append("; "); - - if (afterBlock != null) { - String afterOutput = afterBlock.generate(context).trim(); - - if (afterOutput.endsWith(";")) { - afterOutput = afterOutput.substring(0, afterOutput.length() - 1); - } - - builder.append(afterOutput); - } - - builder.append(") {\n") - .append(getBlock().generate(Context.create(context))) - .append("\n}\n"); - - return generatedCache = builder.toString(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/ForeachLoop.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/ForeachLoop.java deleted file mode 100644 index 532a1b3d0a9..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/ForeachLoop.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.control; - -import org.jboss.errai.codegen.AbstractStatement; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.Variable; - -import static org.jboss.errai.codegen.builder.callstack.LoadClassReference.getClassReference; - -/** - * Foreach statement (enhanced for loop). - * - * @author Christian Sadilek - */ -public class ForeachLoop extends AbstractStatement { - - private final Variable loopVar; - private final String collectionExpr; - private final Statement body; - private final boolean nullSafe; - - public ForeachLoop(Variable loopVar, String collectionExpr, Statement body, boolean nullSafe) { - this.loopVar = loopVar; - this.collectionExpr = collectionExpr; - this.body = body; - this.nullSafe = nullSafe; - } - - String generatedCache; - - @Override - public String generate(Context context) { - if (generatedCache != null) return generatedCache; - - return generatedCache - = ((nullSafe) ? "if (" + collectionExpr + " != null) {\n" : "") - + "for (" + getClassReference(loopVar.getType(), context) - + " " + loopVar.getName() + " : " + collectionExpr + ") {" - + "\n\t" + body.generate(context).replaceAll("\n", "\n\t") - + "\n}" - + ((nullSafe) ? "\n}" : ""); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/IfBlock.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/IfBlock.java deleted file mode 100644 index 081f06e2158..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/IfBlock.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.control; - -import org.jboss.errai.codegen.BlockStatement; -import org.jboss.errai.codegen.BooleanExpression; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.builder.impl.BooleanExpressionBuilder; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public class IfBlock extends AbstractConditionalBlock { - private final BlockStatement elseBlock = new BlockStatement(); - private IfBlock elseIfBlock; - - public IfBlock(BooleanExpression condition) { - super(condition); - } - - @Override - public BooleanExpressionBuilder getCondition() { - return (BooleanExpressionBuilder) super.getCondition(); - } - - public BlockStatement getElseBlock() { - return elseBlock; - } - - public IfBlock getElseIfBlock() { - return elseIfBlock; - } - - public void setElseIfBlock(IfBlock elseIfBlock) { - this.elseIfBlock = elseIfBlock; - } - - String generatedCache; - - @Override - public String generate(Context context) { - if (generatedCache != null) return generatedCache; - - final StringBuilder builder = new StringBuilder("if "); - builder.append("(").append(getCondition().generate(context)).append(") "); - - builder.append("{\n"); - - if (getBlock() != null) { - builder.append(getBlock().generate(Context.create(context))); - } - - builder.append("\n} "); - - if (elseIfBlock != null) { - builder.append("else ").append(elseIfBlock.generate(Context.create(context))); - return builder.toString(); - } - - if (elseBlock != null && !elseBlock.isEmpty()) { - builder.append("else {\n").append(elseBlock.generate(Context.create(context))).append("\n} "); - return builder.toString(); - } - - return generatedCache = builder.toString(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/SwitchBlock.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/SwitchBlock.java deleted file mode 100644 index 13078190e11..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/SwitchBlock.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.control; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import org.jboss.errai.codegen.AbstractStatement; -import org.jboss.errai.codegen.BlockStatement; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.exception.InvalidTypeException; -import org.jboss.errai.codegen.literal.LiteralValue; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; - -/** - * @author Christian Sadilek - */ -public class SwitchBlock extends AbstractStatement { - private static final List> supportedTypes; - static { - supportedTypes = new ArrayList>(Arrays.asList(Integer.class, Character.class, Short.class, Byte.class, Enum.class, String.class)); - } - - private Statement switchExprStmt; - private String switchExpr; - private final Map, BlockStatement> caseBlocks = new LinkedHashMap, BlockStatement>(); - private BlockStatement defaultBlock; - - public SwitchBlock() {} - - public SwitchBlock(Statement switchExprStmt) { - this.switchExprStmt = switchExprStmt; - } - - public void addCase(LiteralValue value) { - caseBlocks.put(value, new BlockStatement()); - } - - public BlockStatement getCaseBlock(LiteralValue value) { - return caseBlocks.get(value); - } - - public BlockStatement getDefaultBlock() { - if (defaultBlock == null) - defaultBlock = new BlockStatement(); - - return defaultBlock; - } - - public void setSwitchExpr(Statement switchExprStmt) { - this.switchExprStmt = switchExprStmt; - } - - public void setSwitchExpr(String expr) { - this.switchExpr = expr; - } - - @Override - public String generate(Context context) { - final StringBuilder buf = new StringBuilder("switch ("); - if (switchExpr == null) { - buf.append(switchExprStmt.generate(context)).append(") {\n "); - } - else { - buf.append(switchExpr).append(") {\n "); - } - - checkSwitchExprType(); - - if (!caseBlocks.isEmpty()) { - final MetaClass switchExprMetaClass = switchExprStmt.getType().getErased().asBoxed(); - final boolean isStringSwitch = switchExprMetaClass.asClass().equals(String.class); - for (final LiteralValue value : caseBlocks.keySet()) { - if (!switchExprMetaClass.isAssignableFrom(value.getType().getErased())) { - throw new InvalidTypeException( - value.generate(context) + " is not a valid value for " + switchExprStmt.getType().getFullyQualifiedName()); - } - String val = value.generate(context); - if (!isStringSwitch) { - // case labels must be unqualified - final int idx = val.lastIndexOf('.'); - if (idx != -1) { - val = val.substring(idx + 1); - } - } - buf.append("case ").append(val).append(": ").append(getCaseBlock(value).generate(Context.create(context))) - .append("\n"); - } - } - - if (defaultBlock != null) { - buf.append("default: ").append(defaultBlock.generate(Context.create(context))).append("\n"); - } - - return buf.append("}").toString(); - } - - private void checkSwitchExprType() { - final boolean validType = supportedTypes.stream() - .anyMatch(cls -> MetaClassFactory.get(cls).isAssignableFrom(switchExprStmt.getType().asBoxed())); - - if (!validType) - throw new InvalidTypeException("Type not permitted in switch statements:" + - switchExprStmt.getType().getFullyQualifiedName()); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/TryBlock.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/TryBlock.java deleted file mode 100644 index 925e7273b4d..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/TryBlock.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.control; - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.jboss.errai.codegen.AbstractStatement; -import org.jboss.errai.codegen.BlockStatement; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Variable; - -/** - * @author Christian Sadilek - */ -public class TryBlock extends AbstractStatement { - private final BlockStatement block = new BlockStatement(); - private final Map catchBlocks = new LinkedHashMap(); - private BlockStatement finallyBlock = null; - - public BlockStatement getBlock() { - return block; - } - - public void addCatchBlock(Variable exception) { - catchBlocks.put(exception, new BlockStatement()); - } - - public BlockStatement getCatchBlock(Variable exceptionVar) { - return catchBlocks.get(exceptionVar); - } - - public BlockStatement getFinallyBlock() { - if (finallyBlock == null) - finallyBlock = new BlockStatement(); - - return finallyBlock; - } - - String generatedCache; - @Override - public String generate(Context context) { - if (generatedCache != null) return generatedCache; - final StringBuilder buf = new StringBuilder("try {\n"); - buf.append(block.generate(context)).append("\n} "); - - if (!catchBlocks.isEmpty()) { - for (final Variable exception : catchBlocks.keySet()) { - final Context ctx = Context.create(context).addVariable(exception); - buf.append("catch (").append(exception.generate(ctx)).append(") ") - .append("{\n") - .append(catchBlocks.get(exception).generate(ctx)) - .append("\n} "); - } - } - else if (finallyBlock == null) { - finallyBlock = new BlockStatement(); - } - - if (finallyBlock != null) { - final Context ctx = Context.create(context); - buf.append(" finally {\n").append(finallyBlock.generate(ctx)).append("\n}\n"); - } - - return generatedCache = buf.toString(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/WhileLoop.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/WhileLoop.java deleted file mode 100644 index 795ff7f562f..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/WhileLoop.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.control; - -import org.jboss.errai.codegen.BlockStatement; -import org.jboss.errai.codegen.BooleanExpression; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.builder.impl.BooleanExpressionBuilder; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public class WhileLoop extends AbstractConditionalBlock { - public WhileLoop(BooleanExpressionBuilder condition) { - super(condition); - } - - public WhileLoop(BooleanExpression condition, BlockStatement block) { - super(condition, block); - } - - public WhileLoop(BooleanExpressionBuilder condition, BlockStatement block) { - super(condition, block); - } - - @Override - public BooleanExpressionBuilder getCondition() { - return (BooleanExpressionBuilder) super.getCondition(); - } - - String generatedCache; - - @Override - public String generate(Context context) { - if (generatedCache != null) return generatedCache; - final StringBuilder builder = new StringBuilder("while (") - .append(getCondition().generate(context)).append(") {\n"); - - if (getBlock() != null) { - builder.append(getBlock().generate(context)); - } - - builder.append("\n}"); - - return generatedCache = builder.toString(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/branch/AbstractBranchStatement.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/branch/AbstractBranchStatement.java deleted file mode 100644 index 7047bf8b677..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/branch/AbstractBranchStatement.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.control.branch; - -import org.jboss.errai.codegen.AbstractStatement; -import org.jboss.errai.codegen.Context; - -/** - * @author Christian Sadilek - */ -public abstract class AbstractBranchStatement extends AbstractStatement { - protected String label; - - public AbstractBranchStatement() {} - - public AbstractBranchStatement(String label) { - this.label = label; - } - - public String generateLabelReference(Context context) { - if (label != null) - return " " + context.getLabel(label).generate(context); - - return ""; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/branch/BreakStatement.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/branch/BreakStatement.java deleted file mode 100644 index 306116b149b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/branch/BreakStatement.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.control.branch; - -import org.jboss.errai.codegen.Context; - -/** - * @author Christian Sadilek - */ -public class BreakStatement extends AbstractBranchStatement { - - public BreakStatement() {} - - public BreakStatement(String label) { - super(label); - } - - @Override - public String generate(Context context) { - return "break" + generateLabelReference(context); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/branch/ContinueStatement.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/branch/ContinueStatement.java deleted file mode 100644 index 8fbfb840081..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/branch/ContinueStatement.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.control.branch; - -import org.jboss.errai.codegen.Context; - -/** - * @author Christian Sadilek - */ -public class ContinueStatement extends AbstractBranchStatement { - - public ContinueStatement() {} - - public ContinueStatement(String label) { - super(label); - } - - @Override - public String generate(Context context) { - return "continue" + generateLabelReference(context); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/branch/Label.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/branch/Label.java deleted file mode 100644 index e43eb569dfc..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/branch/Label.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.control.branch; - -import org.jboss.errai.codegen.AbstractStatement; -import org.jboss.errai.codegen.Context; - -/** - * @author Christian Sadilek - */ -public class Label extends AbstractStatement { - private final String name; - - public static Label create(String name) { - return new Label(name); - } - - private Label(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - @Override - public String generate(Context context) { - return name+":"; - } - - public LabelReference getReference() { - return new LabelReference(name); - } - - @Override - public String toString() { - return "Label [name=" + name + "]"; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/branch/LabelReference.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/branch/LabelReference.java deleted file mode 100644 index 1c0f1f28146..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/control/branch/LabelReference.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.control.branch; - -import org.jboss.errai.codegen.AbstractStatement; -import org.jboss.errai.codegen.Context; - -/** - * @author Christian Sadilek - */ -public class LabelReference extends AbstractStatement { - private final String name; - - public LabelReference(String name) { - this.name = name; - } - - @Override - public String generate(Context context) { - return name; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/CyclicalObjectGraphException.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/CyclicalObjectGraphException.java deleted file mode 100644 index 3b8de649732..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/CyclicalObjectGraphException.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.exception; - -import java.util.Collection; - - -/** - * @author Jonathan Fuerth - */ -public class CyclicalObjectGraphException extends GenerationException { - private static final long serialVersionUID = 1L; - - private final Collection objectsInvolvedInCycle; - - public CyclicalObjectGraphException(Collection objectsInvolvedInCycle) { - super("Unsupported cycle detected in object graph. Objects involved in cycle: " + objectsInvolvedInCycle); - this.objectsInvolvedInCycle = objectsInvolvedInCycle; - } - - public Collection getObjectsInvolvedInCycle() { - return objectsInvolvedInCycle; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/GenerationException.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/GenerationException.java deleted file mode 100644 index aceb2a1e66b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/GenerationException.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.exception; - -/** - * Base class for failures in the Errai code generation module. - *

- * Note to users of this class: instead of throwing an instance of this base - * class, please consider reusing one of its subtypes, or create a new subtype - * if none of the existing ones are suitable. - * - * @author Mike Brock - * @author Christian Sadilek - * @author Jonathan Fuerth - */ -public class GenerationException extends RuntimeException { - private static final long serialVersionUID = 1L; - - private String additionalFailureInfo = ""; - - /** - * Creates a GenerationException with no message and no cause. - */ - public GenerationException() { - super(); - } - - /** - * Creates a GenerationException with the given message and no cause. - */ - public GenerationException(String msg) { - super(msg); - } - - /** - * Creates a GenerationException with no message and the given cause. - */ - public GenerationException(Throwable t) { - super(t); - } - - /** - * Creates a GenerationException with the given message and the given cause. - */ - public GenerationException(String message, Throwable cause) { - super(message, cause); - } - - /** - * Adds the given message to this exception. All additional failure - * information added this way is returned by {@link #getMessage()}. - * - * @param info The additional information to add. - */ - public void appendFailureInfo(String info) { - additionalFailureInfo += "\n" + info; - } - - /** - * Returns this exception's message (as given in the constructor) plus all of - * the additional failure information, separated by newlines. - * - * @see GenerationException#appendFailureInfo(String) - */ - @Override - public String getMessage() { - return super.getMessage() + additionalFailureInfo; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/InvalidExpressionException.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/InvalidExpressionException.java deleted file mode 100644 index 0b0bcc442ae..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/InvalidExpressionException.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.exception; - -/** - * @author Christian Sadilek - */ -public class InvalidExpressionException extends GenerationException { - private static final long serialVersionUID = 1L; - - public InvalidExpressionException() { - super(); - } - - public InvalidExpressionException(Throwable t) { - super(t); - } - - public InvalidExpressionException(String msg) { - super(msg); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/InvalidTypeException.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/InvalidTypeException.java deleted file mode 100644 index e99ab7a7c33..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/InvalidTypeException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.exception; - -/** - * @author Christian Sadilek - */ -public class InvalidTypeException extends GenerationException { - private static final long serialVersionUID = 1L; - - public InvalidTypeException() { - super(); - } - - public InvalidTypeException(Throwable cause) { - super(cause); - } - - public InvalidTypeException(String msg) { - super(msg); - } - - public InvalidTypeException(String msg, Throwable cause) { - super(msg, cause); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/NotLiteralizableException.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/NotLiteralizableException.java deleted file mode 100644 index f7745933d35..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/NotLiteralizableException.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.exception; - -/** - * Thrown when a LiteralValue is requested for an object that cannot be - * represented as a LiteralValue. - * - * @author Jonathan Fuerth - */ -public class NotLiteralizableException extends GenerationException { - - private final Object nonLiteralizableObject; - - /** - * Creates a new NotLiteralizableException that arose as a result of - * requesting a LiteralValue of the given object. - * - * @param nonLiteralizableObject - * the object that is not literalizable. - */ - public NotLiteralizableException(Object nonLiteralizableObject) { - super("Not literalizable: " + - (nonLiteralizableObject == null ? "null" : nonLiteralizableObject.toString()) + - " (of type " + (nonLiteralizableObject == null ? "void" : nonLiteralizableObject.getClass().getName()) + ")"); - this.nonLiteralizableObject = nonLiteralizableObject; - } - - /** - * Returns the object that could not be literalized. - * - * @return The object that could not be literalized. - */ - public Object getNonLiteralizableObject() { - return nonLiteralizableObject; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/OutOfScopeException.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/OutOfScopeException.java deleted file mode 100644 index 2f10f14e5e2..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/OutOfScopeException.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.exception; - -/** - * @author Christian Sadilek - */ -public class OutOfScopeException extends GenerationException { - private static final long serialVersionUID = 1L; - - public OutOfScopeException() { - super(); - } - - public OutOfScopeException(String msg) { - super(msg); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/TypeNotIterableException.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/TypeNotIterableException.java deleted file mode 100644 index fc26fe892d4..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/TypeNotIterableException.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.exception; - -/** - * @author Christian Sadilek - */ -public class TypeNotIterableException extends GenerationException { - private static final long serialVersionUID = 1L; - - public TypeNotIterableException() { - super(); - } - - public TypeNotIterableException(String msg) { - super(msg); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/UndefinedConstructorException.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/UndefinedConstructorException.java deleted file mode 100644 index a996679270f..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/UndefinedConstructorException.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.exception; - -import java.util.Arrays; - -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Christian Sadilek - */ -public class UndefinedConstructorException extends GenerationException { - private static final long serialVersionUID = 1L; - - private MetaClass type; - private MetaClass[] parameterTypes; - - public UndefinedConstructorException() { - super(); - } - - public UndefinedConstructorException(String msg) { - super(msg); - } - - public UndefinedConstructorException(String msg, Throwable cause) { - super(msg, cause); - } - - public UndefinedConstructorException(MetaClass type, MetaClass... parameterTypes) { - this.type = type; - this.parameterTypes = parameterTypes; - } - - public UndefinedConstructorException(MetaClass type, Throwable cause, MetaClass... parameterTypes) { - super(cause); - this.type = type; - this.parameterTypes = parameterTypes; - } - - @Override - public String toString() { - final StringBuilder buf = new StringBuilder(128); - - buf.append(super.toString()).append(": class:").append(type.getFullyQualifiedName()).append(" parameterTypes:"); - Arrays.stream(parameterTypes).forEach(type -> buf.append(type.getFullyQualifiedName()).append(" ")); - return buf.toString(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/UndefinedFieldException.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/UndefinedFieldException.java deleted file mode 100644 index 6a0d9541864..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/UndefinedFieldException.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.exception; - -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public class UndefinedFieldException extends GenerationException { - private static final long serialVersionUID = 1L; - - private String fieldName; - private MetaClass declaringClass; - - public UndefinedFieldException() { - super(); - } - - public UndefinedFieldException(String msg) { - super(msg); - } - - public UndefinedFieldException(String fieldName, MetaClass declaringClass) { - this("could not resolve field: " + fieldName + "; in class: " + declaringClass.getFullyQualifiedName()); - this.fieldName = fieldName; - this.declaringClass = declaringClass; - } - - @Override - public String toString() { - return getMessage(); - } - - public String getFieldName() { - return fieldName; - } - - public MetaClass getDeclaringClass() { - return declaringClass; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/UndefinedMethodException.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/UndefinedMethodException.java deleted file mode 100644 index 79edbf8486b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/UndefinedMethodException.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.exception; - -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.util.GenUtil; - -/** - * @author Christian Sadilek - */ -public class UndefinedMethodException extends GenerationException { - private static final long serialVersionUID = 1L; - - private MetaClass declaringClass; - private String methodName; - private MetaClass[] parameterTypes; - - public UndefinedMethodException() { - super(); - } - - public UndefinedMethodException(String msg) { - super(msg); - } - - public UndefinedMethodException(MetaClass declaringClass, String methodName, MetaClass... parameterTypes) { - super("undefined method: " + methodName + "(" + GenUtil.classesAsStrings(parameterTypes) + "); in class: " - + declaringClass.getFullyQualifiedName()); - this.declaringClass = declaringClass; - this.methodName = methodName; - this.parameterTypes = parameterTypes; - } - - public MetaClass getDeclaringClass() { - return declaringClass; - } - - public String getMethodName() { - return methodName; - } - - public MetaClass[] getParameterTypes() { - return parameterTypes; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/UnproxyableClassException.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/UnproxyableClassException.java deleted file mode 100644 index 5febf6b6891..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/exception/UnproxyableClassException.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.exception; - -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public class UnproxyableClassException extends GenerationException { - private static final long serialVersionUID = 1L; - - private MetaClass clazz; - - public UnproxyableClassException(MetaClass clazz, String message) { - super(message); - this.clazz = clazz; - } - - public MetaClass getUnproxyableClass() { - return clazz; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/AnnotationLiteral.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/AnnotationLiteral.java deleted file mode 100644 index 43b6e734304..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/AnnotationLiteral.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.literal; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Array; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.builder.callstack.LoadClassReference; -import org.jboss.errai.codegen.meta.MetaClassFactory; - -/** - * @author Mike Brock - */ -public class AnnotationLiteral extends LiteralValue { - - public AnnotationLiteral(final Annotation value) { - super(value); - } - - @Override - public String getCanonicalString(final Context context) { - final Class annotationClass = getValue().annotationType(); - final StringBuilder builder = new StringBuilder(); - - builder.append("@").append(LoadClassReference.getClassReference(MetaClassFactory.get(annotationClass), context)); - - final List sortedMethods = Arrays.asList(annotationClass.getDeclaredMethods()); - Collections.sort(sortedMethods, new Comparator() { - @Override - public int compare(final Method m1, final Method m2) { - return m1.getName().compareTo(m2.getName()); - } - - }); - - final List elements = new ArrayList(); - - String lastMethodRendered = ""; - String lastValueRendered; - Set enumTypes = new HashSet(); - - for (final Method method : sortedMethods) { - if (((method.getModifiers() & (Modifier.PRIVATE | Modifier.PROTECTED)) == 0) - && (!"equals".equals(method.getName()) && !"hashCode".equals(method.getName()))) { - method.setAccessible(true); - lastMethodRendered = method.getName(); - lastValueRendered = getLiteral(context, method); - elements.add(lastMethodRendered + " = " + lastValueRendered); - if (method.getReturnType().isEnum()) { - enumTypes.add(method.getReturnType().getSimpleName()); - } - } - } - - final Iterator els = elements.iterator(); - if (els.hasNext()) { - builder.append("("); - } - while (els.hasNext()) { - builder.append(els.next()); - if (els.hasNext()) builder.append(", "); - else builder.append(")"); - } - - String toReturn = builder.toString().replaceAll("new (String|int|long|float|double|boolean|byte|short|char|Class)\\[\\]", ""); - for (String enumType : enumTypes) { - toReturn = toReturn.replaceAll("new " + enumType + "\\[\\]", ""); - } - - if (elements.size() == 1 && "value".endsWith(lastMethodRendered)) { - toReturn = toReturn.replaceFirst("(\\s)*value =(\\s)+", ""); - } - - return toReturn; - } - - private String getLiteral(Context context, Method method) { - try { - Class methodType = method.getReturnType(); - Object methodValue = method.invoke(getValue()); - - if (method.getReturnType().isArray()) { - return getArrayLiteral(context, methodType, methodValue); - } else { - return getNonArrayLiteral(context, methodType, methodValue); - } - } catch (IllegalAccessException e) { - throw new RuntimeException("error generation annotation wrapper", e); - } catch (InvocationTargetException e) { - throw new RuntimeException("error generation annotation wrapper", e); - } - } - - private String getArrayLiteral(Context context, Class type, Object obj) { - if (Array.getLength(obj) == 1) { - return getNonArrayLiteral(context, type.getComponentType(), Array.get(obj, 0)); - } else if (type.getComponentType().isAnnotation()) { - String result = "{ "; - Annotation[] annotations = (Annotation[]) obj; - for (int i = 0; i < annotations.length; i++) { - result += getNonArrayLiteral(context, type.getComponentType(), annotations[i]); - if ((i + 1) != annotations.length) { - result += ", "; - } - } - result += " }"; - return result; - } else { - return LiteralFactory.getLiteral(obj).getCanonicalString(context); - } - } - - private String getNonArrayLiteral(Context context, Class type, Object obj) { - if (type.isAnnotation()) { - return new AnnotationLiteral((Annotation) obj).getCanonicalString(context); - } else { - return LiteralFactory.getLiteral(obj).getCanonicalString(context); - } - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/ArrayLiteral.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/ArrayLiteral.java deleted file mode 100644 index e5ef343a75d..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/ArrayLiteral.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.literal; - -import java.lang.reflect.Array; -import java.lang.reflect.Type; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.builder.callstack.LoadClassReference; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.meta.MetaType; -import org.jboss.errai.codegen.util.GenUtil; - -/** - * Renders an array back to it's canonical Java-based literal representation, assuming the contents - * of the array can be represented as such. - * - * @author Mike Brock - * @author Christian Sadilek - */ -public class ArrayLiteral extends LiteralValue { - private final int dimensions; - private final Class arrayType; - private final MetaClass mArrayType; - - public ArrayLiteral(final Object value) { - super(value); - - Class type = value.getClass(); - int dim = 0; - while (type.isArray()) { - dim++; - type = type.getComponentType(); - } - - this.dimensions = dim; - - if (MetaClass.class.isAssignableFrom(type)) { - type = Class.class; - } - else if (MetaType.class.isAssignableFrom(type)) { - type = Type.class; - } - - this.arrayType = type; - - mArrayType = MetaClassFactory.get(arrayType).asArrayOf(dim); - } - - @Override - public String getCanonicalString(final Context context) { - final StringBuilder buf = new StringBuilder("new " + - LoadClassReference.getClassReference(MetaClassFactory.get(arrayType), context)); - - final Object val = getValue(); - - for (int i = 0; i < dimensions; i++) { - buf.append("[]"); - } - buf.append(" "); - buf.append(renderInlineArrayLiteral(context, val)); - - return buf.toString(); - } - - private static String renderInlineArrayLiteral(final Context context, final Object arrayInstance) { - final StringBuilder builder = new StringBuilder("{ "); - - final int length = Array.getLength(arrayInstance); - - Object element; - - for (int i = 0; i < length; i++) { - element = Array.get(arrayInstance, i); - - if (element == null) { - builder.append("null"); - } - else if (element.getClass().isArray()) { - builder.append(renderInlineArrayLiteral(context, element)); - - } - else { - builder.append(GenUtil.generate(context, element).generate(context)); - } - - if (i + 1 < length) { - builder.append(", "); - } - } - - return builder.append(" }").toString(); - } - - @Override - public MetaClass getType() { - return mArrayType; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/BooleanValue.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/BooleanValue.java deleted file mode 100644 index f1f3025a839..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/BooleanValue.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.literal; - -import org.jboss.errai.codegen.Context; - -/** - * @author Mike Brock - */ -public class BooleanValue extends LiteralValue { - - public BooleanValue(final Boolean value) { - super(value); - } - - @Override - public String getCanonicalString(final Context context) { - return getValue().toString(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/ByteValue.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/ByteValue.java deleted file mode 100644 index c500799a00d..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/ByteValue.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.literal; - -import org.jboss.errai.codegen.Context; - -/** - * @author Mike Brock - */ -public class ByteValue extends LiteralValue { - - public ByteValue(Byte value) { - super(value); - } - - public ByteValue(Integer value) { - super(value.byteValue()); - } - - @Override - public String getCanonicalString(Context context) { - return String.valueOf(getValue().intValue()); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/CharValue.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/CharValue.java deleted file mode 100644 index 950af3bdf97..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/CharValue.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.literal; - -import org.jboss.errai.codegen.Context; - -/** - * @author Mike Brock - */ -public class CharValue extends LiteralValue { - - public CharValue(final Character value) { - super(value); - } - - @Override - public String getCanonicalString(final Context context) { - return "'"+getValue().toString()+"'"; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/ClassLiteral.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/ClassLiteral.java deleted file mode 100644 index 0f5bb5cc950..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/ClassLiteral.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.literal; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; - -import static org.jboss.errai.codegen.builder.callstack.LoadClassReference.getClassReference; - -/** - * @author Mike Brock - */ -public class ClassLiteral extends LiteralValue> implements TypeLiteral { - - public ClassLiteral(final Class value) { - super(value); - } - - @Override - public String getCanonicalString(final Context context) { - if (context == null) { - return getValue().getName() + ".class"; - } else { - return getClassReference(MetaClassFactory.get(getValue()), context) + ".class"; - } - } - - @Override - public MetaClass getType() { - return MetaClassFactory.get(Class.class); - } - - public MetaClass getActualType() { - return super.getType(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/DoubleValue.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/DoubleValue.java deleted file mode 100644 index 9459a61e3d4..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/DoubleValue.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.literal; - -import org.jboss.errai.codegen.Context; - -/** - * @author Mike Brock - */ -public class DoubleValue extends LiteralValue { - - public DoubleValue(final Double value) { - super(value); - } - - @Override - public String getCanonicalString(final Context context) { - return getValue().toString() + "d"; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/FloatValue.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/FloatValue.java deleted file mode 100644 index f0da42e6a36..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/FloatValue.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.literal; - -import org.jboss.errai.codegen.Context; - -/** - * @author Mike Brock - */ -public class FloatValue extends LiteralValue { - - public FloatValue(final Float value) { - super(value); - } - - @Override - public String getCanonicalString(final Context context) { - return getValue().toString() + "f"; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/IntValue.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/IntValue.java deleted file mode 100644 index 3fd7646595b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/IntValue.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.literal; - -import org.jboss.errai.codegen.Context; - -/** - * @author Mike Brock - */ -public class IntValue extends LiteralValue { - - public IntValue(final Integer value) { - super(value); - } - - @Override - public String getCanonicalString(final Context context) { - return getValue().toString(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/ListValue.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/ListValue.java deleted file mode 100644 index ecccfa0771c..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/ListValue.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.literal; - -import java.util.ArrayList; -import java.util.List; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.builder.AnonymousClassStructureBuilder; -import org.jboss.errai.codegen.builder.BlockBuilder; -import org.jboss.errai.codegen.builder.impl.ObjectBuilder; -import org.jboss.errai.codegen.util.Stmt; - -/** - * @author Mike Brock - */ -public class ListValue extends LiteralValue { - public ListValue(final List value) { - super(value); - } - - @Override - public String getCanonicalString(final Context context) { - final BlockBuilder initBlock - = ObjectBuilder.newInstanceOf(ArrayList.class, context).extend().initialize(); - - for (final Object v : getValue()) { - initBlock.append(Stmt.loadVariable("this").invoke("add", LiteralFactory.getLiteral(context, v))); - } - - return initBlock.finish().finish().toJavaString(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/LiteralFactory.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/LiteralFactory.java deleted file mode 100644 index 2e1044c6e4e..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/LiteralFactory.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.literal; - -import java.lang.annotation.Annotation; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.jboss.errai.codegen.AnnotationEncoder; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.RenderCacheStore; -import org.jboss.errai.codegen.SnapshotMaker; -import org.jboss.errai.codegen.exception.NotLiteralizableException; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; - -import static org.jboss.errai.codegen.builder.callstack.LoadClassReference.getClassReference; - -/** - * The literal factory provides a LiteralValue for the specified object (if possible). - * - * @author Mike Brock - */ -public class LiteralFactory { - - - /** - * Returns a literal value (specialization of Statement) representing the - * given object in the given context. - * - * @param o - * The object to create a literal value for. - * - * @return a LiteralValue for the given object. Never null. - * - * @throws NotLiteralizableException - * if {@code o} cannot be literalized - */ - public static LiteralValue getLiteral(final Object o) { - return getLiteral(null, o); - } - - /** - * Returns a literal value (specialization of Statement) representing the - * given object in the given context. - * - * @param context - * The context the literal value will be code-generated in. Contexts - * can specify additional literalizable types. See {@link Context#addLiteralizableClass(Class)}. - * @param o - * The object to create a literal value for. - * - * @return a LiteralValue for the given object. Never null. - * - * @throws NotLiteralizableException - * if {@code o} cannot be literalized - */ - public static LiteralValue getLiteral(final Context context, final Object o) { - return getLiteral(context, o, true); - } - - private static final RenderCacheStore> CLASS_LITERAL_RENDER_CACHE = - () -> "LITERAL_CACHE_STORE"; - - /** - * Implementation for the public getLiteral() methods. - * - * @param context - * The context the literal value will be code-generated in. Contexts - * can specify additional literalizable types. - * @param o - * The object to create a literal value for. - * - * @return a LiteralValue for the given object. Never null. - * - * @throws NotLiteralizableException - * if {@code o} cannot be literalized - */ - private static LiteralValue getLiteral(final Context context, - final Object o, - final boolean throwIfNotLiteralizable) { - Map> LITERAL_CACHE = null; - if (context != null) { - LITERAL_CACHE = context.getRenderingCache(CLASS_LITERAL_RENDER_CACHE); - } - - LiteralValue result = LITERAL_CACHE != null ? LITERAL_CACHE.get(o) : null; - if (result == null) { - - if (o instanceof MetaClass) { - result = new MetaClassLiteral((MetaClass) o); - } - else if (o instanceof Annotation) { - result = new LiteralValue((Annotation) o) { - @Override - public String getCanonicalString(final Context context) { - return AnnotationEncoder.encode((Annotation) o).generate(context); - } - }; - } - else if (o instanceof Enum) { - result = new LiteralValue((Enum) o) { - @Override - public String getCanonicalString(final Context context) { - return getClassReference(MetaClassFactory.get(o.getClass()), context) + "." + ((Enum) o).name(); - } - }; - } - else { - result = _getLiteral(context, o, throwIfNotLiteralizable); - } - - // avoid caching the null; we don't want that returned from the cache! - if (result != null && LITERAL_CACHE != null) { - LITERAL_CACHE.put(o, result); - } - } - - return result; - } - - private static LiteralValue _getLiteral(final Context context, - final Object o, - final boolean throwIfNotLiteralizable) { - if (o == null) { - return NullLiteral.INSTANCE; - } - - if (o instanceof String) { - return new StringLiteral((String) o); - } - else if (o instanceof Integer) { - return new IntValue((Integer) o); - } - else if (o instanceof Character) { - return new CharValue((Character) o); - } - else if (o instanceof Boolean) { - return new BooleanValue((Boolean) o); - } - else if (o instanceof Short) { - return new ShortValue((Short) o); - } - else if (o instanceof Long) { - return new LongValue((Long) o); - } - else if (o instanceof Double) { - return new DoubleValue((Double) o); - } - else if (o instanceof Float) { - return new FloatValue((Float) o); - } - else if (o instanceof Byte) { - return new ByteValue((Byte) o); - } - else if (o instanceof Class) { - return new ClassLiteral((Class) o); - } - else if (o instanceof MetaClass) { - return new MetaClassLiteral((MetaClass) o); - } - else if (o instanceof Set) { - return new SetValue((Set) o); - } - else if (o instanceof List) { - return new ListValue((List) o); - } - else if (o instanceof Map) { - return new MapValue((Map) o); - } - else if (o.getClass().isArray()) { - return new ArrayLiteral(o); - } - else if (context != null && context.isLiteralizableClass(o.getClass())) { - // the new instance of LiteralValue here provides surprising (but desirable) caching behaviour. - // see LiteralTest.testGenerateObjectArrayThenModifyThenGenerateAgain for details. - return new LiteralValue(o) { - @Override - public String getCanonicalString(final Context context) { - final Class targetType = context.getLiteralizableTargetType(o.getClass()); - return SnapshotMaker.makeSnapshotAsSubclass(o, targetType, targetType, null).generate(context); - } - }; - } - else { - if (throwIfNotLiteralizable) { - throw new NotLiteralizableException(o); - } - return null; - } - } - - /** - * Returns a literal value (specialization of Statement) representing the - * given object in the given context, or null if the value is not - * literalizable. - * - * @param o - * The object to create a literal value for. - * - * @return a LiteralValue for the given object, or null if the value cannot be - * expressed as a literal. - */ - public static LiteralValue isLiteral(final Object o) { - return getLiteral(null, o, false); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/LiteralValue.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/LiteralValue.java deleted file mode 100644 index 9abc7762837..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/LiteralValue.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.literal; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.util.GenUtil; - -/** - * @author Mike Brock - */ -public abstract class LiteralValue implements Statement { - private final T value; - protected Class clazz; - - public abstract String getCanonicalString(Context context); - - protected LiteralValue(final T value) { - this.value = value; - } - - public T getValue() { - return value; - } - - @Override - public String generate(final Context context) { - final Statement internedStatement = context.intern(this); - - if (internedStatement != null) { - boolean permissiveMode = GenUtil.isPermissiveMode(); - GenUtil.setPermissiveMode(true); - String s = internedStatement.generate(context); - GenUtil.setPermissiveMode(permissiveMode); - return s; - } - else { - return getCanonicalString(context); - } - } - - @Override - public MetaClass getType() { - if (value == null) - return MetaClassFactory.get(Object.class); - - return Class.class.isAssignableFrom(value.getClass()) - ? MetaClassFactory.get((Class) value) : MetaClassFactory.get(value.getClass()); - } - - @Override - public int hashCode() { - return (value == null) ? 0 : value.hashCode(); - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - final LiteralValue other = (LiteralValue) obj; - if (value == null) { - if (other.value != null) - return false; - } - else if (!value.equals(other.value)) - return false; - return true; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/LongValue.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/LongValue.java deleted file mode 100644 index bee7e719e93..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/LongValue.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.literal; - -import org.jboss.errai.codegen.Context; - -/** - * @author Mike Brock - */ -public class LongValue extends LiteralValue { - - public LongValue(final Long value) { - super(value); - } - - @Override - public String getCanonicalString(final Context context) { - return getValue().toString() + "L"; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/MapValue.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/MapValue.java deleted file mode 100644 index 48209c2c824..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/MapValue.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.literal; - -import java.util.HashMap; -import java.util.Map; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.builder.AnonymousClassStructureBuilder; -import org.jboss.errai.codegen.builder.BlockBuilder; -import org.jboss.errai.codegen.builder.impl.ObjectBuilder; -import org.jboss.errai.codegen.util.Stmt; - -/** - * @author Mike Brock - */ -public class MapValue extends LiteralValue> { - public MapValue(final Map value) { - super(value); - } - - @Override - public String getCanonicalString(final Context context) { - final BlockBuilder initBlock - = ObjectBuilder.newInstanceOf(HashMap.class, context).extend().initialize(); - - for (final Map.Entry v : getValue().entrySet()) { - initBlock.append(Stmt.loadVariable("this").invoke("put", LiteralFactory.getLiteral(v.getKey()), - LiteralFactory.getLiteral(v.getValue()))); - } - - return initBlock.finish().finish().toJavaString(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/MetaClassLiteral.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/MetaClassLiteral.java deleted file mode 100644 index 16be5fe6803..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/MetaClassLiteral.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.literal; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; - -import static org.jboss.errai.codegen.builder.callstack.LoadClassReference.getClassReference; - -/** - * @author Mike Brock - */ -public class MetaClassLiteral extends LiteralValue implements TypeLiteral { - - public MetaClassLiteral(final MetaClass value) { - super(value); - } - - @Override - public String generate(final Context context) { - return getCanonicalString(context); - } - - public String getCanonicalString(final Context context) { - if (context == null) { - return getValue().getFullyQualifiedName() + ".class"; - } - else { - return getClassReference(getValue(), context, false) + ".class"; - } - } - - public MetaClass getType() { - return MetaClassFactory.get(Class.class); - } - - public MetaClass getActualType() { - return getValue(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/NullLiteral.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/NullLiteral.java deleted file mode 100644 index 6bb1cbe5e5b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/NullLiteral.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.literal; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.mvel2.util.NullType; - -/** - * @author Mike Brock - */ -public class NullLiteral extends LiteralValue { - public static final NullLiteral INSTANCE = new NullLiteral(); - - private NullLiteral() { - super(null); - } - - @Override - public String getCanonicalString(final Context context) { - return "null"; - } - - @Override - public MetaClass getType() { - return MetaClassFactory.get(NullType.class); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/SetValue.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/SetValue.java deleted file mode 100644 index 743efbd6cf1..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/SetValue.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.literal; - -import java.util.HashSet; -import java.util.Set; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.builder.AnonymousClassStructureBuilder; -import org.jboss.errai.codegen.builder.BlockBuilder; -import org.jboss.errai.codegen.builder.impl.ObjectBuilder; -import org.jboss.errai.codegen.util.Stmt; - -/** - * @author Mike Brock - */ -public class SetValue extends LiteralValue { - public SetValue(final Set value) { - super(value); - } - - @Override - public String getCanonicalString(final Context context) { - final BlockBuilder initBlock - = ObjectBuilder.newInstanceOf(HashSet.class, context).extend().initialize(); - - for (final Object v : getValue()) { - initBlock.append(Stmt.loadVariable("this").invoke("add", LiteralFactory.getLiteral(v))); - } - - return initBlock.finish().finish().toJavaString(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/ShortValue.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/ShortValue.java deleted file mode 100644 index 255e4d5889c..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/ShortValue.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.literal; - -import org.jboss.errai.codegen.Context; - -/** - * @author Mike Brock - */ -public class ShortValue extends LiteralValue { - - public ShortValue(final Short value) { - super(value); - } - - @Override - public String getCanonicalString(final Context context) { - return getValue().toString(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/StringLiteral.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/StringLiteral.java deleted file mode 100644 index 98b3c7a13b2..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/StringLiteral.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.literal; - -import org.jboss.errai.codegen.Context; - -/** - * @author Mike Brock - */ -public class StringLiteral extends LiteralValue { - public StringLiteral(final String value) { - super(value); - } - - @Override - public String getCanonicalString(final Context context) { - final StringBuilder builder = new StringBuilder("\""); - for (final char c : getValue().toCharArray()) { - switch (c) { - case '\\': - case '"': - builder.append("\\").append(c); - break; - case '\n': - builder.append("\\n"); - break; - case '\r': - builder.append("\\r"); - break; - case '\t': - builder.append("\\t"); - break; - default: - builder.append(c); - } - } - return builder.append("\"").toString(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/TypeLiteral.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/TypeLiteral.java deleted file mode 100644 index 94932e89012..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/literal/TypeLiteral.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.literal; - -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Mike Brock - */ -public interface TypeLiteral { - public MetaClass getActualType(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/AbstractHasAnnotations.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/AbstractHasAnnotations.java deleted file mode 100644 index 6a02e60e792..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/AbstractHasAnnotations.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta; - -import java.lang.annotation.Annotation; -import java.util.HashSet; -import java.util.Set; - -import org.jboss.errai.common.client.api.Assert; - -/** - * Contains shared functionality by all implementations of - * {@link HasAnnotations}. - * - * @author Christian Sadilek - */ -public abstract class AbstractHasAnnotations implements HasAnnotations { - - private Set annotationPresentCache = null; - - /** - * Checks if the provided annotation is present on this element (type, method, - * field or parameter). - * - * @param annotation - * the annotation type, must not be null. - * @return true if annotation is present, otherwise false. - */ - @Override - public boolean isAnnotationPresent(final Class annotation) { - Assert.notNull(annotation); - if (annotationPresentCache == null) { - annotationPresentCache = new HashSet(); - for (final Annotation a : getAnnotations()) { - annotationPresentCache.add(a.annotationType().getName()); - } - } - - return annotationPresentCache.contains(annotation.getName()); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/BeanDescriptor.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/BeanDescriptor.java deleted file mode 100644 index 3824a3ca5f2..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/BeanDescriptor.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta; - -import java.util.Set; - -/** - * @author Mike Brock - * @author Christian Sadilek - * @author Jonathan Fuerth - */ -public interface BeanDescriptor { - public String getBeanName(); - /** - * Get all bean properties associated with this bean type. - * - * @return a set of properties associated with this bean type. - */ - public Set getProperties(); - - public MetaMethod getReadMethodForProperty(String propertyName); - - public MetaMethod getWriteMethodForProperty(String propertyName); - - public MetaClass getPropertyType(String propertyName); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/HasAnnotations.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/HasAnnotations.java deleted file mode 100644 index 6f9f29aad99..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/HasAnnotations.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta; - -import java.lang.annotation.Annotation; -import java.util.Arrays; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public interface HasAnnotations { - public Annotation[] getAnnotations(); - - public default boolean isAnnotationPresent(final Class annotation) { - return getAnnotation(annotation) != null; - } - - @SuppressWarnings("unchecked") - public default A getAnnotation(final Class annotation) { - // Please no hate or else null. - return (A) Arrays.stream(getAnnotations()) - .filter(a -> a.annotationType().equals(annotation)) - .findFirst() - .orElse(null); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaClass.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaClass.java deleted file mode 100644 index 6eacc209a5f..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaClass.java +++ /dev/null @@ -1,260 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta; - -import java.lang.annotation.Annotation; -import java.util.Collection; -import java.util.List; - -/** - * @author Mike Brock - */ -public abstract class MetaClass extends AbstractHasAnnotations implements MetaType, MetaGenericDeclaration { - @Override - public abstract String getName(); - - public abstract String getFullyQualifiedName(); - - public abstract String getFullyQualifiedNameWithTypeParms(); - - public abstract String getCanonicalName(); - - public abstract String getInternalName(); - - public abstract String getPackageName(); - - /** - * Returns all declared and inherited public, protected, and package-private methods - * available on this class. - */ - public abstract MetaMethod[] getMethods(); - - /** - * Returns all declared and inherited methods on this class that have the - * given annotation targeting them. - *

- * - * @param annotation - * The annotation to scan this class's methods for. Must not be null. - * @return An unmodifiable list of all declared and inherited methods of this - * class that are annotated with the given annotation. - * @throws NullPointerException - * if {@code annotation} is null. - */ - public abstract List getMethodsAnnotatedWith(Class annotation); - - public abstract List getDeclaredMethodsAnnotatedWith(Class annotation); - - public abstract List getMethodsWithMetaAnnotations(Class annotation); - - public abstract MetaMethod[] getDeclaredMethods(); - - public abstract MetaMethod getMethod(String name, Class... parameters); - - public abstract MetaMethod getMethod(String name, MetaClass... parameters); - - public abstract MetaMethod getBestMatchingMethod(String name, Class... parameters); - - public abstract MetaMethod getBestMatchingMethod(String name, MetaClass... parameters); - - public abstract MetaMethod getBestMatchingStaticMethod(String name, Class... parameters); - - public abstract MetaMethod getBestMatchingStaticMethod(String name, MetaClass... parameters); - - public abstract MetaMethod getDeclaredMethod(String name, Class... parameters); - - public abstract MetaMethod getDeclaredMethod(String name, MetaClass... parameters); - - public abstract MetaField[] getFields(); - - /** - * Returns all declared and inherited fields on this class that have the - * given annotation targeting them. - * - * @param annotation - * The annotation to scan this class's fields for. Must not be null. - * @return An unmodifiable list of all declared and inherited fields of this - * class that are annotated with the given annotation. - * @throws NullPointerException - * if {@code annotation} is null. - */ - public abstract List getFieldsAnnotatedWith(Class annotation); - - public abstract List getFieldsWithMetaAnnotations(Class annotations); - - public abstract List getParametersAnnotatedWith(Class annotation); - - public abstract MetaField[] getDeclaredFields(); - - public abstract MetaField getField(String name); - - public abstract MetaField getDeclaredField(String name); - - public abstract MetaConstructor[] getConstructors(); - - public abstract MetaConstructor[] getDeclaredConstructors(); - - public abstract MetaClass[] getDeclaredClasses(); - - public abstract MetaConstructor getConstructor(Class... parameters); - - public abstract MetaConstructor getConstructor(MetaClass... parameters); - - public abstract MetaConstructor getBestMatchingConstructor(Class... parameters); - - public abstract MetaConstructor getBestMatchingConstructor(MetaClass... parameters); - - public abstract MetaConstructor getDeclaredConstructor(Class... parameters); - - public abstract MetaConstructor getDeclaredConstructor(MetaClass... parameters); - - public abstract MetaParameterizedType getParameterizedType(); - - public abstract MetaParameterizedType getGenericSuperClass(); - - public abstract MetaClass[] getInterfaces(); - - public abstract MetaClass getSuperClass(); - - public abstract Collection getAllSuperTypesAndInterfaces(); - - public abstract MetaClass getComponentType(); - - public abstract MetaClass getOuterComponentType(); - - /** - * Reports if the type represented by this MetaClass is a supertype of (or the - * same class as) the type represented by the given MetaClass. In other words, - * this method returns true if the following code would compile without error, - * where ThisType is the class represented by this MetaClass object, and - * GivenType is the class represented by the given "clazz" argument: - * - *

-   *   GivenType given = ...;
-   *   ThisType a = given;
-   * 
- * - * @param clazz - * The type to check for assignability to this MetaClass's type. - * @return True if the given type is assignable to this metaclass's type. - */ - public abstract boolean isAssignableFrom(MetaClass clazz); - - public abstract boolean isAssignableTo(MetaClass clazz); - - /** - * Reports if the type represented by this MetaClass is a supertype of (or the - * same class as) the given class. In other words, this method returns true if - * the following code would compile without error, where ThisType is the class - * represented by this MetaClass object, and GivenType is the class - * represented by the given "clazz" argument: - * - *
-   *   GivenType given = ...;
-   *   ThisType a = given;
-   * 
- * - * @param clazz The type to check for assignability to this MetaClass's type. - * @return True if the given type is assignable to this metaclass's type. - */ - public abstract boolean isAssignableFrom(Class clazz); - - public abstract boolean isAssignableTo(Class clazz); - - public abstract boolean isDefaultInstantiableSubtypeOf(String fqcn); - - public abstract boolean isPrimitive(); - - public abstract boolean isInterface(); - - public abstract boolean isAbstract(); - - public abstract boolean isArray(); - - public abstract boolean isEnum(); - - public abstract boolean isAnnotation(); - - public abstract boolean isPublic(); - - public abstract boolean isPrivate(); - - public abstract boolean isProtected(); - - public abstract boolean isFinal(); - - public abstract boolean isStatic(); - - public abstract boolean isVoid(); - - public abstract boolean isDefaultInstantiable(); - - public abstract boolean isSynthetic(); - - public abstract boolean isAnonymousClass(); - - public boolean isConcrete() { - return !isInterface() - && !isAbstract() - && !isSynthetic() - && !isAnonymousClass() - && !isPrimitive() - && !isArray() - && !isAnnotation() - && !isEnum(); - } - - public abstract MetaClass asBoxed(); - - public abstract MetaClass asUnboxed(); - - public abstract MetaClass asArrayOf(int dimensions); - - /** - * Returns a MetaClass that represents the same class as this one, but - * guaranteed to have no type parameters. - * - * @return A raw MetaClass representing the same class as this MetaClass. If - * this class has no type parameters in the first place, the receiving - * MetaClass instance is returned. - */ - public abstract MetaClass getErased(); - - public abstract boolean isPrimitiveWrapper(); - - public abstract Class asClass(); - - /** - * Searches for the named field in this type, its superinterfaces, and its superclasses. - *

- * The search proceeds as in {@link #getField(String)}, but includes all public, protected, default accessibility, and - * private fields. Whether a field is static or not does not affect this search. - * - * @param name The name of the field to search for. Not null. - * @return The first field with the given name that was encountered by the search. - */ - public abstract MetaField getInheritedField(String name); - - public abstract BeanDescriptor getBeanDescriptor(); - - public abstract int hashContent(); - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaClassCache.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaClassCache.java deleted file mode 100644 index dd863c005b4..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaClassCache.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.stream.Collectors; - -import org.jboss.errai.common.rebind.CacheStore; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author Mike Brock - */ -public class MetaClassCache implements CacheStore { - private static final Logger logger = LoggerFactory.getLogger(MetaClassCache.class); - - private final Map PRIMARY_CLASS_CACHE - = new ConcurrentHashMap(2000); - - private final Map PERMANENT_CLASS_CACHE - = new ConcurrentHashMap(2000); - - private final Map ERASED_CLASS_CACHE - = new ConcurrentHashMap(2000); - - private final Set invalidated = Collections.newSetFromMap(new ConcurrentHashMap()); - private final Set added = Collections.newSetFromMap(new ConcurrentHashMap()); - private final Set removed = Collections.newSetFromMap(new ConcurrentHashMap()); - private final Map backupClassCache = new ConcurrentHashMap(); - - @Override - public void clear() { - backupClassCache.clear(); - backupClassCache.putAll(PRIMARY_CLASS_CACHE); - - invalidated.clear(); - removed.clear(); - added.clear(); - - PRIMARY_CLASS_CACHE.clear(); - ERASED_CLASS_CACHE.clear(); - - PRIMARY_CLASS_CACHE.putAll(PERMANENT_CLASS_CACHE); - } - - public void updateCache(Map mapToPush) { - logger.debug("updateCache called for " + mapToPush.size() + " MetaClasses."); - addNewOrUpdatedToInvalidated(mapToPush); - addRemoved(); - } - - private void addRemoved() { - final Set oldKeys = new HashSet(backupClassCache.keySet()); - oldKeys.removeAll(PRIMARY_CLASS_CACHE.keySet()); - - for (final String clazzName : oldKeys) { - if (backupClassCache.get(clazzName).hashCode != CacheEntry.PLACE_HOLDER) - removed.add(clazzName); - } - } - - private void addNewOrUpdatedToInvalidated(Map mapToPush) { - for (final Entry entry : mapToPush.entrySet()) { - logger.trace("Creating new " + entry.getValue().getClass().getSimpleName() + " cache entry for " + entry.getKey()); - final CacheEntry newCacheEntry = createCacheEntry(entry.getValue()); - PRIMARY_CLASS_CACHE.put(entry.getKey(), newCacheEntry); - final CacheEntry previousCacheEntry = backupClassCache.get(entry.getKey()); - if (previousCacheEntry == null || previousCacheEntry.hashCode != newCacheEntry.hashCode) { - logger.trace("Old cache entry replaced for " + entry.getKey()); - invalidated.add(entry.getKey()); - - if (previousCacheEntry == null) { - added.add(entry.getValue()); - } - } - } - } - - public void pushCache(final MetaClass clazz) { - pushCache(clazz.getFullyQualifiedName(), clazz); - } - - public void pushCache(final String fqcn, final MetaClass clazz) { - logger.trace("Creating new " + clazz.getClass().getSimpleName() + " cache entry for " + fqcn); - if (!PRIMARY_CLASS_CACHE.containsKey(fqcn)) { - PRIMARY_CLASS_CACHE.put(fqcn, new CacheEntry(clazz, CacheEntry.PLACE_HOLDER)); - if (!backupClassCache.containsKey(clazz.getFullyQualifiedName())) { - invalidated.add(fqcn); - } - } - } - - public void pushToPermanentCache(final MetaClass clazz) { - pushToPermanentCache(clazz.getFullyQualifiedName(), clazz); - } - - public void pushToPermanentCache(final String fullyQualifiedName, final MetaClass clazz) { - logger.trace("Creating new permanent " + clazz.getClass().getSimpleName() + " cache entry for " + fullyQualifiedName); - pushCache(fullyQualifiedName, clazz); - PERMANENT_CLASS_CACHE.put(fullyQualifiedName, PRIMARY_CLASS_CACHE.get(fullyQualifiedName)); - } - - public MetaClass get(String fqcn) { - final CacheEntry entry = PRIMARY_CLASS_CACHE.get(fqcn); - return (entry != null) ? entry.cachedClass : null; - } - - public Collection getAllCached() { - return PRIMARY_CLASS_CACHE.values().stream().filter(c -> c != null).map(c -> c.cachedClass).collect(Collectors.toList()); - } - - public Collection getAllNewOrUpdated() { - return invalidated.stream().map(fcqn -> PRIMARY_CLASS_CACHE.get(fcqn).cachedClass).collect(Collectors.toList()); - } - - public Set getAllDeletedClasses() { - return Collections.unmodifiableSet(removed); - } - - public Set getAllNewClasses() { - return Collections.unmodifiableSet(added); - } - - public boolean isKnownErasedType(final String fqcn) { - return ERASED_CLASS_CACHE.containsKey(fqcn); - } - - public MetaClass getErased(final String fqcn) { - return ERASED_CLASS_CACHE.get(fqcn); - } - - public void pushErasedCache(final String fqcn, final MetaClass clazz) { - logger.trace("Creating new " + clazz.getClass().getSimpleName() + " cache entry for " + fqcn); - ERASED_CLASS_CACHE.put(fqcn, clazz); - } - - public int size() { - return PRIMARY_CLASS_CACHE.size(); - } - - public boolean isKnownType(String fqcn) { - return PRIMARY_CLASS_CACHE.containsKey(fqcn); - } - - public boolean isNewOrUpdated(String fqcn) { - return invalidated.contains(fqcn); - } - - private class CacheEntry { - final MetaClass cachedClass; - final int hashCode; - - static final int PLACE_HOLDER = 0; - - CacheEntry(final MetaClass cachedClass, final int hashCode) { - this.cachedClass = cachedClass; - this.hashCode = hashCode; - } - } - - private CacheEntry createCacheEntry(final MetaClass cachedClass) { - return new CacheEntry(cachedClass, cachedClass.hashContent()); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaClassFactory.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaClassFactory.java deleted file mode 100644 index 0c8286dfa7c..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaClassFactory.java +++ /dev/null @@ -1,635 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta; - -import java.io.File; -import java.lang.reflect.Array; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.Type; -import java.net.URL; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; - -import javax.enterprise.util.TypeLiteral; - -import org.jboss.errai.codegen.BlockStatement; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.DefParameters; -import org.jboss.errai.codegen.Parameter; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.ThrowsDeclaration; -import org.jboss.errai.codegen.builder.callstack.LoadClassReference; -import org.jboss.errai.codegen.meta.impl.build.BuildMetaClass; -import org.jboss.errai.codegen.meta.impl.build.BuildMetaConstructor; -import org.jboss.errai.codegen.meta.impl.build.BuildMetaField; -import org.jboss.errai.codegen.meta.impl.build.BuildMetaMethod; -import org.jboss.errai.codegen.meta.impl.build.BuildMetaParameterizedType; -import org.jboss.errai.codegen.meta.impl.build.ShadowBuildMetaField; -import org.jboss.errai.codegen.meta.impl.build.ShadowBuildMetaMethod; -import org.jboss.errai.codegen.meta.impl.java.JavaReflectionClass; -import org.jboss.errai.codegen.util.ClassChangeUtil; -import org.jboss.errai.codegen.util.EmptyStatement; -import org.jboss.errai.codegen.util.GenUtil; -import org.jboss.errai.common.metadata.RebindUtils; -import org.jboss.errai.common.rebind.CacheUtil; -import org.mvel2.ConversionHandler; -import org.mvel2.DataConversion; - -/** - * @author Mike Brock - */ -public final class MetaClassFactory { - static { - DataConversion.addConversionHandler(Class.class, new ConversionHandler() { - @Override - public Object convertFrom(final Object in) { - if (MetaClass.class.isAssignableFrom(in.getClass())) { - return ((MetaClass) in).asClass(); - } - else { - throw new RuntimeException("cannot convert from " + in.getClass() + "; to " + Class.class.getName()); - } - } - - @Override - public boolean canConvertFrom(final Class cls) { - return MetaType.class.isAssignableFrom(cls); - } - }); - - DataConversion.addConversionHandler(Class[].class, new ConversionHandler() { - @Override - public Object convertFrom(final Object in) { - final int length = Array.getLength(in); - final Class[] cls = new Class[length]; - - for (int i = 0; i < length; i++) { - final Object el = Array.get(in, i); - - if (el instanceof MetaClass) { - cls[i] = ((MetaClass) el).asClass(); - } - else if (el != null && el.getClass().isArray()) { - cls[i] = (Class) convertFrom(el); - } - else { - cls[i] = null; - } - } - return cls; - } - - @Override - public boolean canConvertFrom(Class cls) { - while (cls.isArray()) { - cls = cls.getComponentType(); - } - return MetaClass.class.isAssignableFrom(cls) || MetaType.class.isAssignableFrom(cls); - } - }); - } - - private static MetaClassCache cache; - - public static MetaClassCache getMetaClassCache() { - if (cache == null) { - cache = CacheUtil.getCache(MetaClassCache.class); - } - return cache; - } - - public static MetaClass get(final String fullyQualifiedClassName, final boolean erased) { - return createOrGet(fullyQualifiedClassName, erased); - } - - public static MetaClass get(final String fullyQualifiedClassName) { - return createOrGet(fullyQualifiedClassName); - } - - public static MetaClass get(final Class clazz) { - if (clazz == null) - return null; - return createOrGet(clazz, null); - } - - public static MetaClass getArrayOf(final Class clazz, final int dims) { - final int[] da = new int[dims]; - for (int i = 0; i < da.length; i++) { - da[i] = 0; - } - - return getArrayOf(clazz, da); - } - - public static MetaClass getArrayOf(final Class clazz, int... dims) { - if (dims.length == 0) { - dims = new int[1]; - } - return JavaReflectionClass.newInstance(Array.newInstance(clazz, dims).getClass()); - } - - public static MetaClass get(final Class clazz, final Type type) { - return createOrGet(clazz, type); - } - - public static MetaClass get(final TypeLiteral literal) { - return createOrGet(literal); - } - - public static MetaMethod get(final Method method) { - return get(method.getDeclaringClass()).getDeclaredMethod(method.getName(), method.getParameterTypes()); - } - - public static MetaField get(final Field field) { - return get(field.getDeclaringClass()).getDeclaredField(field.getName()); - } - - public static Statement getAsStatement(final Class clazz) { - return getAsStatement(createOrGet(clazz.getName(), false)); - } - - public static Statement getAsStatement(final MetaClass metaClass) { - return new Statement() { - @Override - public String generate(final Context context) { - return LoadClassReference.getClassReference(metaClass, context); - } - - @Override - public MetaClass getType() { - return MetaClassFactory.get(Class.class); - } - }; - } - - public static boolean isCached(final String name) { - return getMetaClassCache().isKnownErasedType(name); - } - - private static MetaClass createOrGet(final String fullyQualifiedClassName) { - if (!getMetaClassCache().isKnownErasedType(fullyQualifiedClassName)) { - return createOrGet(fullyQualifiedClassName, false); - } - - return getMetaClassCache().getErased(fullyQualifiedClassName); - } - - private static MetaClass createOrGet(final TypeLiteral type) { - if (type == null) - return null; - - if (!getMetaClassCache().isKnownErasedType(type.toString())) { - final MetaClass gwtClass = JavaReflectionClass.newUncachedInstance(type); - - addLookups(type, gwtClass); - return gwtClass; - } - - return getMetaClassCache().getErased(type.toString()); - } - - private static MetaClass createOrGet(final String clsName, final boolean erased) { - if (clsName == null) - return null; - - MetaClass mCls; - if (erased) { - mCls = getMetaClassCache().getErased(clsName); - if (mCls == null) { - getMetaClassCache().pushErasedCache(clsName, mCls = JavaReflectionClass.newUncachedInstance(loadClass(clsName), erased)); - } - } - else { - mCls = getMetaClassCache().get(clsName); - if (mCls == null) { - getMetaClassCache().pushCache(clsName, mCls = JavaReflectionClass.newUncachedInstance(loadClass(clsName), erased)); - } - } - return mCls; - } - - private static MetaClass createOrGet(final Class cls, final Type type) { - if (cls == null) - return null; - - if (type != null) { - if (cls.getTypeParameters() != null) { - return JavaReflectionClass.newUncachedInstance(cls, type); - } - - if (!getMetaClassCache().isKnownErasedType(cls.getName())) { - final MetaClass javaReflectionClass = JavaReflectionClass.newUncachedInstance(cls, type); - addLookups(cls, javaReflectionClass); - return javaReflectionClass; - } - - return getMetaClassCache().getErased(cls.getName()); - } - else { - MetaClass mCls; - mCls = getMetaClassCache().get(cls.getName()); - if (mCls == null) { - getMetaClassCache().pushCache(cls.getName(), mCls = JavaReflectionClass.newUncachedInstance(cls)); - } - return mCls; - } - } - - public static MetaClass parameterizedAs(final Class clazz, final MetaParameterizedType parameterizedType) { - return parameterizedAs(MetaClassFactory.get(clazz), parameterizedType); - } - - public static MetaClass parameterizedAs(final MetaClass clazz, final MetaParameterizedType parameterizedType) { - return parameterizedAs(clazz, parameterizedType, true); - } - - public static MetaClass parameterizedAs(final MetaClass clazz, - final MetaParameterizedType parameterizedType, - final boolean reifyRecursively) { - return cloneToBuildMetaClass(clazz, parameterizedType, reifyRecursively); - } - - private static BuildMetaClass cloneToBuildMetaClass(final MetaClass clazz) { - return cloneToBuildMetaClass(clazz, null, false); - } - - private static BuildMetaClass cloneToBuildMetaClass(final MetaClass clazz, - final MetaParameterizedType parameterizedType, - final boolean reifyRecursively) { - final BuildMetaClass buildMetaClass = new BuildMetaClass(null, clazz.getFullyQualifiedName()); - - buildMetaClass.setReifiedFormOf(clazz); - buildMetaClass.setAbstract(clazz.isAbstract()); - buildMetaClass.setFinal(clazz.isFinal()); - buildMetaClass.setStatic(clazz.isStatic()); - buildMetaClass.setInterface(clazz.isInterface()); - addInterfaces(clazz, buildMetaClass, parameterizedType); - buildMetaClass.setScope(GenUtil.scopeOf(clazz)); - buildMetaClass.setSuperClass(clazz.getSuperClass()); - - for (final MetaTypeVariable typeVariable : clazz.getTypeParameters()) { - buildMetaClass.addTypeVariable(typeVariable); - } - - if (parameterizedType != null) { - buildMetaClass.setParameterizedType(parameterizedType); - } - else { - buildMetaClass.setParameterizedType(clazz.getParameterizedType()); - } - - for (final MetaField field : clazz.getDeclaredFields()) { - final BuildMetaField bmf = new ShadowBuildMetaField(buildMetaClass, EmptyStatement.INSTANCE, - GenUtil.scopeOf(field), field.getType(), field.getName(), field); - - bmf.setFinal(field.isFinal()); - bmf.setStatic(field.isStatic()); - bmf.setVolatile(field.isVolatile()); - bmf.setTransient(field.isTransient()); - - buildMetaClass.addField(bmf); - } - - for (final MetaConstructor c : clazz.getDeclaredConstructors()) { - final BuildMetaConstructor newConstructor = new BuildMetaConstructor(buildMetaClass, EmptyStatement.INSTANCE, - GenUtil.scopeOf(c), - DefParameters.from(c)); - newConstructor.setReifiedFormOf(c); - - buildMetaClass.addConstructor(newConstructor); - } - - for (final MetaMethod method : clazz.getDeclaredMethods()) { - - MetaClass returnType = method.getReturnType(); - if (method.getGenericReturnType() instanceof MetaTypeVariable) { - final MetaTypeVariable typeVariable = (MetaTypeVariable) method.getGenericReturnType(); - final MetaClass tVarVal = getTypeVariableValue(typeVariable, buildMetaClass); - if (tVarVal != null) { - returnType = tVarVal; - } - } - else if (method.getGenericReturnType() instanceof MetaParameterizedType) { - final MetaParameterizedType metaParameterizedType - = (MetaParameterizedType) method.getGenericReturnType(); - - final List typeVarValues = new ArrayList(); - boolean defaultOnly = true; - for (final MetaType metaType : metaParameterizedType.getTypeParameters()) { - if (metaType instanceof MetaTypeVariable) { - final MetaTypeVariable typeVariable = (MetaTypeVariable) metaType; - final MetaClass tVarVar = getTypeVariableValue(typeVariable, buildMetaClass); - if (tVarVar != null) { - defaultOnly = false; - typeVarValues.add(tVarVar); - } - else { - typeVarValues.add(MetaClassFactory.get(Object.class)); - } - } - else { - typeVarValues.add(metaType); - } - } - - if (reifyRecursively && !defaultOnly) { - returnType = parameterizedAs(returnType, typeParametersOf(typeVarValues.toArray(new MetaType[typeVarValues.size()])), false); - } - } - - final List parameters = new ArrayList(); - int i = 0; - for (final MetaParameter parm : method.getParameters()) { - MetaClass parmType = null; - if (method.getGenericParameterTypes() != null) { - if (method.getGenericParameterTypes()[i] instanceof MetaTypeVariable) { - final MetaTypeVariable typeVariable = (MetaTypeVariable) method.getGenericParameterTypes()[i]; - - final MetaClass tVarVal = getTypeVariableValue(typeVariable, buildMetaClass); - if (tVarVal != null) { - parmType = tVarVal; - } - } - } - - if (parmType == null) { - parmType = parm.getType(); - } - - parameters.add(Parameter.of(parmType, parm.getName())); - i++; - } - - final BuildMetaMethod newMethod = new ShadowBuildMetaMethod(buildMetaClass, BlockStatement.EMPTY_BLOCK, - GenUtil.scopeOf(method), GenUtil.modifiersOf(method), method.getName(), returnType, - DefParameters.fromParameters(parameters), ThrowsDeclaration.of(method.getCheckedExceptions()), method); - - newMethod.setReifiedFormOf(method); - - buildMetaClass.addMethod(newMethod); - } - - return buildMetaClass; - } - - private static void addInterfaces(final MetaClass clazz, final BuildMetaClass buildMetaClass, final MetaParameterizedType parameterizedType) { - final MetaType[] typeParams = (clazz.getParameterizedType() != null ? clazz.getParameterizedType().getTypeParameters() : clazz.getTypeParameters()); - final MetaType[] typeArgs = parameterizedType.getTypeParameters(); - validateTypeArgumentsAgainstParameters(clazz, typeParams, typeArgs); - - final Map typeArgsByTypeParam = mapTypeArgsByTypeParamName(typeParams, typeArgs); - final List ifaces = Arrays - .stream(clazz.getInterfaces()) - .map(iface -> getParameterizedInterface(typeArgsByTypeParam, iface)) - .collect(Collectors.toList()); - buildMetaClass.setInterfaces(ifaces); - } - - private static BuildMetaClass getParameterizedInterface(final Map typeArgsByTypeParam, final MetaClass iface) { - final MetaType[] ifaceTypeArgs = getTypeArgumentsForInterface(typeArgsByTypeParam, iface); - return cloneToBuildMetaClass(iface, typeParametersOf(ifaceTypeArgs), true); - } - - private static MetaType[] getTypeArgumentsForInterface(final Map typeArgsByTypeParam, final MetaClass iface) { - return Arrays - .stream(Optional.ofNullable(iface.getParameterizedType()) - .map(i -> i.getTypeParameters()) - .orElseGet(() -> iface.getTypeParameters())) - .map(mt -> { - if (typeArgsByTypeParam.containsKey(mt.getName())) { - return typeArgsByTypeParam.get(mt.getName()); - } - else { - return mt; - } - }).toArray(size -> new MetaType[size]); - } - - private static Map mapTypeArgsByTypeParamName(final MetaType[] typeParams, final MetaType[] typeArgs) { - final Map typeArgsByTypeParam = new HashMap<>(); - for (int i = 0; i < typeParams.length; i++) { - typeArgsByTypeParam.put(typeParams[i].getName(), typeArgs[i]); - } - return typeArgsByTypeParam; - } - - private static void validateTypeArgumentsAgainstParameters(final MetaClass clazz, final MetaType[] typeParams, final MetaType[] assignedTypes) { - if (typeParams.length != assignedTypes.length) { - final String message = "Number of provided types does not match the number of type parameters for " + clazz.getFullyQualifiedName() - + ".\nType parameters: " + Arrays.toString(typeParams) - + "\nProvided types: " + Arrays.toString(assignedTypes); - throw new IllegalArgumentException(message); - } - } - - private static MetaClass getTypeVariableValue(final MetaTypeVariable typeVariable, final MetaClass clazz) { - int idx = -1; - final MetaTypeVariable[] typeVariables = clazz.getTypeParameters(); - for (int i = 0; i < typeVariables.length; i++) { - if (typeVariables[i].getName().equals(typeVariable.getName())) { - idx = i; - break; - } - } - - if (idx != -1) { - final MetaType type = clazz.getParameterizedType().getTypeParameters()[idx]; - if (type instanceof MetaClass) { - return (MetaClass) type; - } - } - return null; - } - - public static MetaParameterizedType typeParametersOf(final Object... classes) { - final MetaType[] types = new MetaType[classes.length]; - int i = 0; - for (final Object o : classes) { - if (o instanceof Class) { - types[i++] = MetaClassFactory.get((Class) o); - } - else if (o instanceof TypeLiteral) { - types[i++] = MetaClassFactory.get((TypeLiteral) o); - } - else if (o instanceof MetaType) { - types[i++] = (MetaType) o; - } - else { - throw new RuntimeException("not a recognized type reference: " + o.getClass().getName()); - } - } - - return typeParametersOf(types); - } - - public static MetaParameterizedType typeParametersOf(final Class... classes) { - return typeParametersOf(fromClassArray(classes)); - } - - public static MetaParameterizedType typeParametersOf(final MetaType... classes) { - return new BuildMetaParameterizedType(classes, null, null); - } - - private static void addLookups(final TypeLiteral literal, final MetaClass metaClass) { - getMetaClassCache().pushErasedCache(literal.toString(), metaClass); - } - - private static void addLookups(final Class cls, final MetaClass metaClass) { - getMetaClassCache().pushErasedCache(cls.getName(), metaClass); - } - - public static final Map> PRIMITIVE_LOOKUP = Collections.unmodifiableMap(new HashMap>() { - { - put("void", void.class); - put("boolean", boolean.class); - put("int", int.class); - put("long", long.class); - put("float", float.class); - put("double", double.class); - put("short", short.class); - put("byte", byte.class); - put("char", char.class); - } - }); - - public static Class loadClass(final String fullyQualifiedName) { - try { - Class cls = PRIMITIVE_LOOKUP.get(fullyQualifiedName); - if (cls == null) { - cls = Class.forName(fullyQualifiedName, false, Thread.currentThread().getContextClassLoader()); - } - return cls; - } - catch (final ClassNotFoundException e) { - final URL url = MetaClassFactory.class.getClassLoader() - .getResource(fullyQualifiedName.replace('.', '/') + ".java"); - - if (url != null) { - final File sourceFile = new File(url.getFile()).getAbsoluteFile(); - if (sourceFile.exists()) { - - final File directory = sourceFile.getParentFile(); - final String packageName = fullyQualifiedName.substring(0, fullyQualifiedName.lastIndexOf('.')); - final String className = fullyQualifiedName.substring(fullyQualifiedName.lastIndexOf('.') + 1); - - final String location = ClassChangeUtil.compileClass(directory.getAbsolutePath(), - packageName, - className, - RebindUtils.getTempDirectory() + "/hotload/"); - - try { - return ClassChangeUtil.loadClassDefinition(location, - packageName, className); - } - catch (final Exception e2) { - throw new RuntimeException("Could not load class: " + fullyQualifiedName, e2); - } - } - } - - throw new RuntimeException("Could not load class: " + fullyQualifiedName); - } - } - - public static boolean canLoadClass(final String fullyQualifiedName) { - try { - final Class cls = loadClass(fullyQualifiedName); - return cls != null; - } - catch (final Throwable t) { - return false; - } - } - - public static MetaClass[] fromClassArray(final Class[] classes) { - final MetaClass[] newClasses = new MetaClass[classes.length]; - for (int i = 0; i < classes.length; i++) { - newClasses[i] = createOrGet(classes[i].getName(), false); - } - return newClasses; - } - - public static MetaClass[] asMetaClassArray(final MetaParameter[] parms) { - final MetaClass[] type = new MetaClass[parms.length]; - for (int i = 0; i < parms.length; i++) { - type[i] = parms[i].getType(); - } - return type; - } - - public static Class[] asClassArray(final MetaParameter[] parms) { - final MetaType[] type = new MetaType[parms.length]; - for (int i = 0; i < parms.length; i++) { - type[i] = parms[i].getType(); - } - return asClassArray(type); - } - - public static Class[] asClassArray(final MetaType[] cls) { - final Class[] newClasses = new Class[cls.length]; - for (int i = 0; i < cls.length; i++) { - if (cls[i] instanceof MetaParameterizedType) { - newClasses[i] = ((MetaClass) ((MetaParameterizedType) cls[i]).getRawType()).asClass(); - } - else { - newClasses[i] = ((MetaClass) cls[i]).asClass(); - } - } - return newClasses; - } - - public static Collection getAllNewOrUpdatedClasses() { - return getMetaClassCache().getAllNewOrUpdated(); - } - - public static Collection getNewClasses() { - return getMetaClassCache().getAllNewClasses(); - } - - public static boolean isChangedOrDeleted(final String fqcn) { - return getMetaClassCache().getAllDeletedClasses().contains(fqcn) || getMetaClassCache().isNewOrUpdated(fqcn); - } - - public static Set getAllDeletedClasses() { - return getMetaClassCache().getAllDeletedClasses(); - } - - public static Collection getAllCachedClasses() { - return getMetaClassCache().getAllCached(); - } - - public static boolean isKnownType(final String fqcn) { - return getMetaClassCache().isKnownType(fqcn); - } - - public static boolean hasAnyChanges() { - return !getAllNewOrUpdatedClasses().isEmpty() || !getAllDeletedClasses().isEmpty(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaClassMember.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaClassMember.java deleted file mode 100644 index 96483bd3b6f..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaClassMember.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta; - -/** - * @author Mike Brock - */ -public interface MetaClassMember extends HasAnnotations { - public String getName(); - - public MetaClass getDeclaringClass(); - - public String getDeclaringClassName(); - - public abstract boolean isAbstract(); - - public abstract boolean isPublic(); - - public abstract boolean isPrivate(); - - public abstract boolean isProtected(); - - public abstract boolean isFinal(); - - public abstract boolean isStatic(); - - public abstract boolean isTransient(); - - public abstract boolean isSynthetic(); - - public abstract boolean isVolatile(); - - public abstract boolean isSynchronized(); - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaConstructor.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaConstructor.java deleted file mode 100644 index dfb7f26f45b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaConstructor.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta; - -import java.lang.reflect.Constructor; -import java.util.Arrays; - -public abstract class MetaConstructor extends MetaMethod implements MetaClassMember, MetaGenericDeclaration { - public abstract MetaParameter[] getParameters(); - - public abstract MetaType[] getGenericParameterTypes(); - - public abstract boolean isVarArgs(); - - public Constructor asConstructor() { - try { - final Class cls = Class.forName(getDeclaringClass().getFullyQualifiedName()); - final Class[] parms = MetaClassFactory.asClassArray(getParameters()); - - for (Constructor constructor : cls.getDeclaredConstructors()) { - if (Arrays.equals(parms, constructor.getParameterTypes())) { - return constructor; - } - } - return null; - } - catch (Throwable t) { - return null; - } - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaField.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaField.java deleted file mode 100644 index f17bd0c2586..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaField.java +++ /dev/null @@ -1,250 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; - -import org.jboss.errai.codegen.util.GenUtil; - -public abstract class MetaField extends AbstractHasAnnotations implements MetaClassMember { - - /** - * Returns an actual MetaClass (a class, interface, primitive type, array, or - * enum, but not a type variable or a wildcard) representing an erased - * type that is assignable to this field. - * - * @see #getGenericType() - * @return a MetaClass representing a type that is assignable to this field. - * Never null. - */ - public abstract MetaClass getType(); - - /** - * Returns the actual unerased type of this field, which could be a MetaClass - * (class, enum, interface, array, primitive, etc), a bounded or unbounded - * type variable, or a wildcard. Unlike with {@link #getType()}, any type - * parameters on the field's type will be preserved in the returned MetaType - * object. - * - * @return The field type as declared. Never null. - */ - public abstract MetaType getGenericType(); - - /** - * Returns this field's name without any type information or qualifiers. - * - * @return The field name. Never null. - */ - @Override - public abstract String getName(); - - /** - * Returns the annotations present on this field. - * - * @return A shared reference to the array of the annotations on this field. - * Returns an empty array (never null) if the field has no - * annotations. Callers should refrain from modifying the returned - * array. - */ - @Override - public abstract Annotation[] getAnnotations(); - - /** - * Returns a string which includes the declaring class's name and the field - * type and field name, as well as all declared annotations for that field. - * Do not rely on the format of this string remaining consistent across - * releases of Errai. - */ - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append(MetaField.class.getName()).append(":"); - sb.append(getDeclaringClassName()).append("."); - - Annotation[] annos = getAnnotations(); - if (annos != null) { - for (Annotation anno : annos) { - sb.append(anno.toString()).append(" "); - } - } - - sb.append(GenUtil.scopeOf(this).getCanonicalName()).append(" ") - .append(GenUtil.modifiersOf(this).toJavaString()).append(" ") - .append(this.getType()).append(" ").append(getName()); - - return sb.toString(); - } - - private String _hashString; - - /** - * Returns a string that uniquely identifies this field for purposes of - * comparison with other implementations of {@link MetaField}. The returned - * string includes the declaring class name, the field name, and the field's - * type. - * - * @return - */ - public String hashString() { - if (_hashString != null) return _hashString; - return _hashString = MetaField.class.getName() - + ":" + getDeclaringClass().getFullyQualifiedName() + "." + getName() + "::" + getType().getFullyQualifiedName(); - } - - @Override - public int hashCode() { - return hashString().hashCode(); - } - - - /** - * Compares this MetaField with another MetaField. Differing implenentations - * (for example, GWT vs Java Reflection) compare equal as long as they - * represent the same field of the same class. - */ - @Override - public boolean equals(Object o) { - return o instanceof MetaField && ((MetaField) o).hashString().equals(hashString()); - } - - /** - * Returns the java.lang.reflect.Field object representing this MetaField. - * - * @return The Java Reflection Field object representing the same field as - * this MetaField. Never null. - * @throws IllegalStateException - * if the field or its containing class cannot be located using Java - * Reflection. - */ - public Field asField() { - try { - final Class aClass = getDeclaringClass().asClass(); - return aClass.getDeclaredField(getName()); - } - catch (Throwable e) { - throw new IllegalStateException(e); - } - } - - /** - * Special-purpose implementation of MetaField that represents the - * {@code length} property of an array. - */ - public static class ArrayLengthMetaField extends MetaField implements HasAnnotations { - - private MetaClass componentType; - - public ArrayLengthMetaField(MetaClass componentType) { - this.componentType = componentType; - } - - @Override - public MetaClass getType() { - return MetaClassFactory.get(int.class); - } - - @Override - public MetaType getGenericType() { - return null; - } - - @Override - public String getName() { - return "length"; - } - - @Override - public Annotation[] getAnnotations() { - return new Annotation[0]; - } - - @Override - public MetaClass getDeclaringClass() { - return componentType; - } - - @Override - public String getDeclaringClassName() { - return componentType.getFullyQualifiedName(); - } - - @Override - public boolean isAbstract() { - return false; - } - - @Override - public boolean isPublic() { - return true; - } - - @Override - public boolean isPrivate() { - return false; - } - - @Override - public boolean isProtected() { - return false; - } - - @Override - public boolean isFinal() { - return false; - } - - @Override - public boolean isStatic() { - return false; - } - - @Override - public boolean isTransient() { - return false; - } - - @Override - public boolean isSynthetic() { - return false; - } - - @Override - public boolean isVolatile() { - return false; - } - - @Override - public boolean isSynchronized() { - return false; - } - - @Override - public boolean isAnnotationPresent(Class annotation) { - return false; - } - - @Override - public A getAnnotation(Class annotation) { - return null; - } - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaGenericArrayType.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaGenericArrayType.java deleted file mode 100644 index f0a9ccb1a6e..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaGenericArrayType.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta; - -/** - * @author Mike Brock - */ -public interface MetaGenericArrayType extends MetaType { - public MetaType getGenericComponentType(); - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaGenericDeclaration.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaGenericDeclaration.java deleted file mode 100644 index ceb703b4daf..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaGenericDeclaration.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta; - - -/** - * Umbrella interface for {@link MetaClass}, {@link MetaMethod}, and - * {@link MetaConstructor}: the three places where a generic type variable can - * be declared. - * - * @author Mike Brock - * @author Jonathan Fuerth - */ -public interface MetaGenericDeclaration { - - /** - * Returns the array of type variables declared on this generic declaration - * site, in the order they were declared in the source code. - * - * @return the type variables declared at this site. The returned array is - * never null, but it will be empty if no type variable are declared - * at this site. - */ - public MetaTypeVariable[] getTypeParameters(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaMethod.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaMethod.java deleted file mode 100644 index 3bfb53adb2b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaMethod.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.stream.Collectors; - -import org.jboss.errai.codegen.util.GenUtil; - -public abstract class MetaMethod extends AbstractHasAnnotations implements MetaClassMember, MetaGenericDeclaration { - @Override - public abstract String getName(); - - /** - * Returns the MetaClass representing this method's return type. The returned - * MetaClass may have had its generic information erased. - * - * @return - */ - public abstract MetaClass getReturnType(); - - /** - * Returns the MetaType representing the return type of the method. In the - * case of a plain, non-parameterized return type, this will return a - * {@link MetaClass} equivalent to the one returned by - * {@link MetaMethod#getReturnType()}. Other possible types could be - * {@link MetaWildcardType}, {@link MetaParameterizedType}, and - * {@link MetaTypeVariable}. - *

- * As of Errai 2.2, some implementations of this method are incomplete and - * will return null if they cannot make sense of the method's return type. - * - * @return - */ - public abstract MetaType getGenericReturnType(); - - public abstract MetaType[] getGenericParameterTypes(); - - public abstract MetaParameter[] getParameters(); - - public abstract MetaClass[] getCheckedExceptions(); - - public abstract boolean isVarArgs(); - - private String _hashString; - public String hashString() { - if (_hashString != null) return _hashString; - return _hashString = MetaMethod.class + ":" - + getDeclaringClass().getFullyQualifiedName() + "." + getName() - + "(" + Arrays.toString(getParameters()) + ")"; - } - - @Override - public int hashCode() { - return hashString().hashCode() * 31; - } - - @Override - public boolean equals(Object o) { - return o instanceof MetaMethod && ((MetaMethod)o).hashString().equals(hashString()); - } - - public List getParametersAnnotatedWith(Class annotation) { - return Arrays.stream(getParameters()) - .filter(p -> p.isAnnotationPresent(annotation)) - .collect(Collectors.collectingAndThen(Collectors.toList(), l -> Collections.unmodifiableList(l))); - } - - public Method asMethod() { - try { - final Class cls = Class.forName(getDeclaringClass().getFullyQualifiedName()); - final Class[] parms = MetaClassFactory.asClassArray(getParameters()); - - for (final Method m : cls.getDeclaredMethods()) { - if (m.getName().equals(getName()) && Arrays.equals(parms, m.getParameterTypes())) { - return m; - } - } - return null; - } - catch (final Throwable t) { - return null; - } - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - final Annotation[] annos = getAnnotations(); - if (annos != null) { - for (final Annotation anno : annos) { - sb.append(anno.toString()).append(" "); - } - } - sb.append(" ").append(GenUtil.scopeOf(this).getCanonicalName()).append(" ") - .append(getReturnType()).append(" ") - .append(getName()).append("(").append(Arrays.toString(getParameters())).append(")"); - - return sb.toString(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaParameter.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaParameter.java deleted file mode 100644 index d6b3c56d738..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaParameter.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta; - -/** - * @author Mike Brock - */ -public abstract class MetaParameter extends AbstractHasAnnotations { - public abstract String getName(); - - public abstract MetaClass getType(); - - public abstract MetaClassMember getDeclaringMember(); - - private String _hashString; - private Integer index = null; - - public String hashString() { - if (_hashString != null) return _hashString; - return _hashString = MetaParameter.class.getName() + ":" + getName() + ":" - + getType().getFullyQualifiedName(); - } - - @Override - public int hashCode() { - return hashString().hashCode() * 31; - } - - @Override - public boolean equals(Object o) { - return o instanceof MetaParameter && ((MetaParameter) o).hashString().equals(hashString()); - } - - public Integer getIndex() { - if (index == null) { - final MetaClassMember member = getDeclaringMember(); - final MetaParameter[] params; - if (member instanceof MetaMethod) { - params = ((MetaMethod) member).getParameters(); - } else if (member instanceof MetaConstructor) { - params = ((MetaConstructor) member).getParameters(); - } else { - throw new RuntimeException("Not yet implemented!"); - } - - for (int i = 0; i < params.length; i++) { - if (params[i] == this || params[i].getName().equals(getName())) { - index = i; - - return index; - } - } - - throw new RuntimeException("Could not find index of parameter " + getName() + " in " - + getDeclaringMember().getName() + " in " + getDeclaringMember().getDeclaringClassName()); - } - - return index; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaParameterizedType.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaParameterizedType.java deleted file mode 100644 index a05d1b612cb..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaParameterizedType.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta; - -/** - * @author Mike Brock - */ -public interface MetaParameterizedType extends MetaType { - public MetaType[] getTypeParameters(); - - public MetaType getOwnerType(); - - public MetaType getRawType(); - - public boolean isAssignableFrom(MetaParameterizedType type); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaType.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaType.java deleted file mode 100644 index efbc3505401..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaType.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta; - -/** - * Umbrella type for anything that could be used as a type in Java code: - * MetaClass, MetaParameterizedType, MetaTypeVariable, MetaWildcardType, and - * MetaGenericArrayType all implement this interface. - * - * @author Mike Brock - * @author Jonathan Fuerth - */ -public interface MetaType { - - /** - * Returns the name of this type as it was written in the original source code. - * - * @return The name of this type as it was written in the original source code. - */ - public String getName(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaTypeVariable.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaTypeVariable.java deleted file mode 100644 index 337d8de0d2c..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaTypeVariable.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta; - -/** - * @author Mike Brock - * @author Jonathan Fuerth - */ -public interface MetaTypeVariable extends MetaType { - - /** - * Returns an array of the upper bounds on this type variable. For each entry - * in the array, if the bound can be resolved to a type, it will be resolved - * (the array entry will be a {@link MetaClass} or a - * {@link MetaParameterizedType}); otherwise (the type variable is - * unresolvable) it will be a type variable or a parameterized type with an - * unresolved type variable itself. - */ - public MetaType[] getBounds(); - - // note: Java's TypeVariable interface has a getGenericDeclaration() method that returns the - // class, method, or constructor where the type variable was declared. Unfortunately, this - // information is not available from GWT's type system. - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaWildcardType.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaWildcardType.java deleted file mode 100644 index 75c01c2bf95..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/MetaWildcardType.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta; - -/** - * Represents a wildcard type such as {@code ?}, {@code ? extends List} or - * {@code ? super MyType}. - * - * @author Mike Brock - * @author Jonathan Fuerth - */ -public interface MetaWildcardType extends MetaType { - - /** - * Returns the Java source code representation of this wildcard, for example - * "? extends java.util.Collection" or "? super org.xyz.Foo". - */ - @Override - public String getName(); - - /** - * Equivalent to {@link #getName()}. - */ - @Override - public String toString(); - - /** - * Returns the lower bounds of this wildcard type. Examples: - *

- * - * @return The lower bounds of this wildcard type. The return value is never - * null--if the wildcard has no lower bounds, an empty array is - * returned. - */ - public MetaType[] getLowerBounds(); - - /** - * Returns the upper bounds of this wildcard type. Examples: - *
    - *
  • {@code } has an upper bound of {@code java.lang.Object} - *
  • {@code } has an upper bound of {List} - *
  • {@code } has an upper bound of {@code java.lang.Object} - *
  • {@code } upper bounds of {List, Futzable} - *
- * - * @return The upper bounds of this wildcard type. The return value is never - * null--if the wildcard has no upper bounds, an empty array is - * returned. - */ - public MetaType[] getUpperBounds(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/AbstractMetaClass.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/AbstractMetaClass.java deleted file mode 100644 index dda943b964b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/AbstractMetaClass.java +++ /dev/null @@ -1,859 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta.impl; - -import java.beans.Introspector; -import java.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -import org.jboss.errai.codegen.meta.BeanDescriptor; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.meta.MetaConstructor; -import org.jboss.errai.codegen.meta.MetaField; -import org.jboss.errai.codegen.meta.MetaMethod; -import org.jboss.errai.codegen.meta.MetaParameter; -import org.jboss.errai.codegen.meta.MetaParameterizedType; -import org.jboss.errai.codegen.meta.MetaType; -import org.jboss.errai.codegen.meta.MetaTypeVariable; -import org.jboss.errai.codegen.meta.MetaWildcardType; -import org.jboss.errai.codegen.util.GenUtil; -import org.mvel2.util.NullType; -import org.mvel2.util.ReflectionUtil; - -import static java.util.stream.Collectors.collectingAndThen; -import static org.jboss.errai.codegen.util.GenUtil.classToMeta; -import static org.jboss.errai.codegen.util.GenUtil.getArrayDimensions; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public abstract class AbstractMetaClass extends MetaClass { - private static final MetaClass NULL_TYPE = MetaClassFactory.get(NullType.class); - - protected volatile transient Class _asClassCache; - private volatile transient MetaClass _boxedCache; - private volatile transient MetaClass _unboxedCache; - private volatile transient Boolean _isPrimitiveWrapper; - private volatile transient String _internalNameCache; - private volatile transient MetaClass _outerComponentCache; - - private final T enclosedMetaObject; - protected MetaParameterizedType parameterizedType; - protected MetaParameterizedType genericSuperClass; - private final Map ASSIGNABLE_CACHE = new HashMap<>(); - private MetaMethod[] staticMethodCache; - - protected AbstractMetaClass(final T enclosedMetaObject) { - this.enclosedMetaObject = enclosedMetaObject; - } - - @Override - public String getFullyQualifiedNameWithTypeParms() { - final StringBuilder buf = new StringBuilder(getFullyQualifiedName()); - buf.append(getTypeParmsString(getParameterizedType())); - return buf.toString(); - } - - private String getTypeParmsString(final MetaParameterizedType parameterizedType) { - final StringBuilder buf = new StringBuilder(512); - - if (parameterizedType != null && parameterizedType.getTypeParameters().length != 0) { - buf.append("<"); - for (int i = 0; i < parameterizedType.getTypeParameters().length; i++) { - - final MetaType typeParameter = parameterizedType.getTypeParameters()[i]; - if (typeParameter instanceof MetaParameterizedType) { - final MetaParameterizedType parameterizedTypeParameter = (MetaParameterizedType) typeParameter; - buf.append(((MetaClass) parameterizedTypeParameter.getRawType()).getFullyQualifiedName()); - buf.append(getTypeParmsString(parameterizedTypeParameter)); - } - else if (typeParameter instanceof MetaWildcardType) { - buf.append(((MetaWildcardType) typeParameter).toString()); - } - else if (typeParameter instanceof MetaTypeVariable) { - buf.append(typeParameter.getName()); - } - else { - buf.append(((MetaClass) typeParameter).getFullyQualifiedName()); - } - - if (i + 1 < parameterizedType.getTypeParameters().length) - buf.append(", "); - } - - buf.append(">"); - } - return buf.toString(); - } - - protected static MetaMethod _getMethod(final MetaMethod[] methods, final String name, final MetaClass... parmTypes) { - MetaMethod candidate = null; - int bestScore = 0; - int score; - - for (final MetaMethod method : methods) { - score = 0; - if (method.getName().equals(name)) { - if (method.getParameters().length == parmTypes.length) { - if (parmTypes.length == 0) { - score = 1; - MetaClass retType = method.getReturnType(); - while ((retType = retType.getSuperClass()) != null) - score++; - } - else { - for (int i = 0; i < parmTypes.length; i++) { - if (method.getParameters()[i].getType().isAssignableFrom(parmTypes[i])) { - score++; - if (method.getParameters()[i].getType().equals(parmTypes[i])) { - score++; - } - } - } - } - } - } - - if (score > bestScore) { - bestScore = score; - candidate = method; - } - } - - return candidate; - } - - protected static MetaConstructor _getConstructor(final MetaConstructor[] constructors, final MetaClass... parmTypes) { - MetaConstructor candidate = null; - int bestScore = 0; - int score; - - for (final MetaConstructor constructor : constructors) { - score = 0; - if (constructor.getParameters().length == parmTypes.length) { - if (parmTypes.length == 0) { - score = 1; - } - else { - for (int i = 0; i < parmTypes.length; i++) { - if (constructor.getParameters()[i].getType().isAssignableFrom(parmTypes[i])) { - score++; - if (constructor.getParameters()[i].getType().equals(parmTypes[i])) { - score++; - } - } - } - } - } - - if (score > bestScore) { - bestScore = score; - candidate = constructor; - } - } - - return candidate; - } - - @Override - public MetaMethod getMethod(final String name, final Class... parmTypes) { - return _getMethod(getMethods(), name, classToMeta(parmTypes)); - } - - @Override - public MetaMethod getMethod(final String name, final MetaClass... parameters) { - return _getMethod(getMethods(), name, parameters); - } - - @Override - public MetaMethod getDeclaredMethod(final String name, final Class... parmTypes) { - return _getMethod(getDeclaredMethods(), name, classToMeta(parmTypes)); - } - - @Override - public MetaMethod getDeclaredMethod(final String name, final MetaClass... parmTypes) { - return _getMethod(getDeclaredMethods(), name, parmTypes); - } - - @Override - public MetaMethod getBestMatchingMethod(final String name, final Class... parameters) { - MetaMethod meth = getMethod(name, parameters); - if (meth == null || meth.isStatic()) { - meth = null; - } - - final MetaClass[] mcParms = new MetaClass[parameters.length]; - for (int i = 0; i < parameters.length; i++) { - mcParms[i] = MetaClassFactory.get(parameters[i]); - } - - if (meth == null) { - meth = getBestMatchingMethod(new GetMethodsCallback() { - @Override - public MetaMethod[] getMethods() { - return AbstractMetaClass.this.getMethods(); - } - }, name, mcParms); - } - - return meth; - } - - @Override - public MetaMethod getBestMatchingMethod(final String name, final MetaClass... parameters) { - return getBestMatchingMethod(new GetMethodsCallback() { - @Override - public MetaMethod[] getMethods() { - return AbstractMetaClass.this.getMethods(); - } - }, name, parameters); - } - - @Override - public MetaMethod getBestMatchingStaticMethod(final String name, final Class... parameters) { - MetaMethod meth = getMethod(name, parameters); - if (meth == null || !meth.isStatic()) { - meth = null; - } - - final MetaClass[] mcParms = new MetaClass[parameters.length]; - for (int i = 0; i < parameters.length; i++) { - mcParms[i] = MetaClassFactory.get(parameters[i]); - } - - if (meth == null) { - meth = getBestMatchingMethod(new GetMethodsCallback() { - @Override - public MetaMethod[] getMethods() { - return getStaticMethods(); - } - }, name, mcParms); - } - return meth; - } - - @Override - public MetaMethod getBestMatchingStaticMethod(final String name, final MetaClass... parameters) { - return getBestMatchingMethod(new GetMethodsCallback() { - @Override - public MetaMethod[] getMethods() { - return getStaticMethods(); - } - }, name, parameters); - } - - private static interface GetMethodsCallback { - MetaMethod[] getMethods(); - } - - private MetaMethod getBestMatchingMethod(final GetMethodsCallback methodsCallback, final String name, - final MetaClass... parameters) { - MetaMethod meth = GenUtil.getBestCandidate(parameters, name, this, methodsCallback.getMethods(), false); - if (meth == null) { - meth = GenUtil.getBestCandidate(parameters, name, this, methodsCallback.getMethods(), false); - } - return meth; - } - - private MetaMethod[] getStaticMethods() { - if (staticMethodCache != null) { - return staticMethodCache; - } - - return staticMethodCache = Arrays.stream(getMethods()).filter(m -> m.isStatic()).toArray(s -> new MetaMethod[s]); - } - - @Override - public MetaConstructor getBestMatchingConstructor(final Class... parameters) { - return getBestMatchingConstructor(MetaClassFactory.fromClassArray(parameters)); - } - - @Override - public MetaConstructor getBestMatchingConstructor(final MetaClass... parameters) { - return GenUtil.getBestConstructorCandidate(parameters, this, getDeclaredConstructors(), false); - } - - @Override - public MetaConstructor getConstructor(final Class... parameters) { - return _getConstructor(getConstructors(), classToMeta(parameters)); - } - - @Override - public MetaConstructor getConstructor(final MetaClass... parameters) { - return _getConstructor(getConstructors(), parameters); - } - - @Override - public MetaConstructor getDeclaredConstructor(final Class... parameters) { - return _getConstructor(getDeclaredConstructors(), classToMeta(parameters)); - } - - @Override - public MetaConstructor getDeclaredConstructor(final MetaClass... parameters) { - return _getConstructor(getDeclaredConstructors(), parameters); - } - - @Override - public MetaField getInheritedField(final String name) { - MetaField f = getDeclaredField(name); - if (f != null) - return f; - for (final MetaClass iface : getInterfaces()) { - f = iface.getInheritedField(name); - if (f != null) - return f; - } - if (getSuperClass() != null) { - return getSuperClass().getInheritedField(name); - } - return null; - } - - @Override - public final List getMethodsAnnotatedWith(final Class annotation) { - final Map> methodsByName = new HashMap<>(); - MetaClass scanTarget = this; - while (scanTarget != null) { - for (final MetaMethod m : scanTarget.getDeclaredMethods()) { - if (m.isAnnotationPresent(annotation)) { - final List methods = methodsByName.computeIfAbsent(m.getName(), k -> new ArrayList<>()); - if (isNotOverriden(m, methods)) { - methods.add(m); - } - } - } - scanTarget = scanTarget.getSuperClass(); - } - - return Collections - .unmodifiableList(methodsByName - .values() - .stream() - .flatMap(list -> list.stream()) - .collect(Collectors.toList())); - } - - private boolean isNotOverriden(final MetaMethod method, final List overrideCandidates) { - return !overrideCandidates - .stream() - .anyMatch(m -> { - if (m.getName().equals(method.getName()) && m.getParameters().length == method.getParameters().length) { - for (int i = 0; i < m.getParameters().length; i++) { - final MetaClass candidateOverrideParamType = m.getParameters()[i].getType(); - final MetaClass paramType = method.getParameters()[i].getType(); - if (!candidateOverrideParamType.isAssignableTo(paramType)) { - return false; - } - } - - return true; - } - - return false; - }); - } - - @Override - public List getDeclaredMethodsAnnotatedWith(final Class annotation) { - return Arrays.stream(getDeclaredMethods()) - .filter(m -> m.isAnnotationPresent(annotation)) - .collect(collectingAndThen(Collectors.toList(), l -> Collections.unmodifiableList(l))); - } - - @Override - public List getMethodsWithMetaAnnotations(final Class annotation) { - final List methods = new ArrayList<>(); - MetaClass scanTarget = this; - while (scanTarget != null) { - for (final MetaMethod m : scanTarget.getDeclaredMethods()) { - for (final Annotation a : m.getAnnotations()) { - if (_findMetaAnnotation(a.annotationType(), annotation)) { - methods.add(m); - } - } - } - scanTarget = scanTarget.getSuperClass(); - } - - return methods; - } - - private static boolean _findMetaAnnotation(final Class root, - final Class annotation) { - if (root.isAnnotationPresent(annotation)) { - return true; - } - else { - return Arrays.stream(root.getAnnotations()).anyMatch(a -> _findMetaAnnotation(a.annotationType(), annotation)); - } - } - - @Override - public final List getFieldsAnnotatedWith(final Class annotation) { - final List fields = new ArrayList<>(); - MetaClass scanTarget = this; - while (scanTarget != null) { - for (final MetaField m : scanTarget.getDeclaredFields()) { - if (m.isAnnotationPresent(annotation)) { - fields.add(m); - } - } - scanTarget = scanTarget.getSuperClass(); - } - return Collections.unmodifiableList(fields); - } - - @Override - public List getFieldsWithMetaAnnotations(final Class annotation) { - final List methods = new ArrayList<>(); - MetaClass scanTarget = this; - while (scanTarget != null) { - for (final MetaField m : scanTarget.getDeclaredFields()) { - for (final Annotation a : m.getAnnotations()) { - if (_findMetaAnnotation(a.annotationType(), annotation)) { - methods.add(m); - } - } - } - scanTarget = scanTarget.getSuperClass(); - } - - return methods; - } - - @Override - public List getParametersAnnotatedWith(final Class annotation) { - final List methods = new ArrayList<>(); - MetaClass scanTarget = this; - while (scanTarget != null) { - for (final MetaConstructor m : scanTarget.getDeclaredConstructors()) { - methods.addAll(m.getParametersAnnotatedWith(annotation)); - } - for (final MetaMethod m : scanTarget.getDeclaredMethods()) { - methods.addAll(m.getParametersAnnotatedWith(annotation)); - } - scanTarget = scanTarget.getSuperClass(); - } - - return methods; - } - - public T getEnclosedMetaObject() { - return enclosedMetaObject; - } - - - @Override - public boolean isAssignableFrom(final MetaClass clazz) { - Boolean assignable = ASSIGNABLE_CACHE.get(clazz); - if (assignable != null) { - return assignable; - } - - // XXX not sure if this is uncached on purpose. - // FIXME there are no tests or documentation for this case - if (!isPrimitive() && NULL_TYPE.equals(clazz)) - return true; - - if (isArray() && clazz.isArray()) { - return getOuterComponentType().isAssignableFrom(clazz.getOuterComponentType()) - && getArrayDimensions(this) == getArrayDimensions(clazz); - } - - final MetaClass sup; - - if (getFullyQualifiedName().equals(Object.class.getName())) { - assignable = true; - } - else if (this.getFullyQualifiedName().equals(clazz.getFullyQualifiedName())) { - assignable = true; - } - else if (isInterface() && _hasInterface(clazz.getInterfaces(), this.getErased())) { - assignable = true; - } - else - assignable = (sup = clazz.getSuperClass()) != null && isAssignableFrom(sup); - - ASSIGNABLE_CACHE.put(clazz, assignable); - return assignable; - } - - @Override - public boolean isDefaultInstantiableSubtypeOf(final String fqcn) { - if (!isPublic() || !isDefaultInstantiable()) { - return false; - } - - MetaClass type = this; - while (type != null && !type.getFullyQualifiedName().equals(fqcn)) { - type = type.getSuperClass(); - } - - return type != null; - } - - @Override - public boolean isAssignableTo(final MetaClass clazz) { - return clazz.isAssignableFrom(this); - } - - private static boolean _hasInterface(final MetaClass[] from, final MetaClass to) { - for (final MetaClass interfaceType : from) { - if (to.getFullyQualifiedName().equals(interfaceType.getErased().getFullyQualifiedName())) - return true; - else if (_hasInterface(interfaceType.getInterfaces(), to)) - return true; - } - - return false; - } - - @Override - public boolean isAssignableFrom(final Class clazz) { - return isAssignableFrom(MetaClassFactory.get(clazz)); - } - - @Override - public boolean isAssignableTo(final Class clazz) { - return isAssignableTo(MetaClassFactory.get(clazz)); - } - - @Override - public boolean isDefaultInstantiable() { - if (isInterface() || isAbstract()) { - return false; - } - final MetaConstructor c = getConstructor(new MetaClass[0]); - return c != null && c.isPublic(); - } - - @Override - public MetaParameterizedType getParameterizedType() { - return parameterizedType; - } - - @Override - public MetaParameterizedType getGenericSuperClass() { - return genericSuperClass; - } - - @Override - public Collection getAllSuperTypesAndInterfaces() { - final Collection supersAndIfaces = new LinkedHashSet<>(); - addSuperTypesAndInterfaces(this, supersAndIfaces); - - return supersAndIfaces; - } - - private static void addInterfaces(final MetaClass metaClass, final Collection supersAndIfaces) { - for (final MetaClass iface : metaClass.getInterfaces()) { - supersAndIfaces.add(iface); - addInterfaces(iface, supersAndIfaces); - } - } - - private static void addSuperTypesAndInterfaces(final MetaClass metaClass, final Collection supersAndIfaces) { - if (metaClass == null) { - return; - } - - supersAndIfaces.add(metaClass); - addSuperTypesAndInterfaces(metaClass.getSuperClass(), supersAndIfaces); - addInterfaces(metaClass, supersAndIfaces); - } - - @Override - public synchronized Class asClass() { - if (_asClassCache != null) { - return _asClassCache; - } - - Class cls = MetaClassFactory.PRIMITIVE_LOOKUP.get(getFullyQualifiedName()); - if (cls == null) { - cls = NullType.class; - } - - if (enclosedMetaObject instanceof Class) { - cls = (Class) enclosedMetaObject; - } - else if (isArray()) { - try { - cls = Class.forName(getInternalName().replace('/', '.'), false, - Thread.currentThread().getContextClassLoader()); - } - catch (final ClassNotFoundException e) { - e.printStackTrace(); - cls = null; - } - } - else { - try { - cls = Thread.currentThread().getContextClassLoader().loadClass(getFullyQualifiedName()); - } - catch (final ClassNotFoundException e) { - // ignore. - } - } - - return _asClassCache = cls; - } - - @Override - public synchronized MetaClass asBoxed() { - if (_boxedCache != null) - return _boxedCache; - return _boxedCache = GenUtil.getPrimitiveWrapper(this); - } - - @Override - public synchronized MetaClass asUnboxed() { - if (_unboxedCache != null) - return _unboxedCache; - return _unboxedCache = GenUtil.getUnboxedFromWrapper(this); - } - - @Override - public synchronized boolean isPrimitiveWrapper() { - return _isPrimitiveWrapper != null ? _isPrimitiveWrapper : (_isPrimitiveWrapper = GenUtil.isPrimitiveWrapper(this)); - } - - @Override - public synchronized String getInternalName() { - if (_internalNameCache != null) - return _internalNameCache; - - String name = getFullyQualifiedName(); - - String dimString = ""; - MetaClass type = this; - if (isArray()) { - type = type.getComponentType(); - int dim = 1; - while (type.isArray()) { - dim++; - type = type.getComponentType(); - } - - for (int i = 0; i < dim; i++) { - dimString += "["; - } - - name = type.getFullyQualifiedName(); - } - - if (type.isPrimitive()) { - name = getInternalPrimitiveNameFrom(name.trim()); - } - else { - name = "L".concat(getInternalPrimitiveNameFrom(name.trim()).replace('.', '/')).concat(";"); - } - - return _internalNameCache = dimString + name; - } - - public static String getInternalPrimitiveNameFrom(final String name) { - if ("int".equals(name)) { - return "I"; - } - else if ("boolean".equals(name)) { - return "Z"; - } - else if ("byte".equals(name)) { - return "B"; - } - else if ("char".equals(name)) { - return "C"; - } - else if ("short".equals(name)) { - return "S"; - } - else if ("long".equals(name)) { - return "J"; - } - else if ("float".equals(name)) { - return "F"; - } - else if ("double".equals(name)) { - return "D"; - } - else if ("void".equals(name)) { - return "V"; - } - return name; - } - - @Override - public BeanDescriptor getBeanDescriptor() { - return new BeanDescriptor() { - private final Set properties; - private final Map getterProperties; - private final Map setterProperties; - - { - final Set properties = new HashSet<>(); - final Map getterProperties = new HashMap<>(); - final Map setterProperties = new HashMap<>(); - - for (final MetaMethod method : getMethods()) { - final String property = ReflectionUtil.getPropertyFromAccessor(method.getName()); - - if (method.getParameters().length == 0 - && (method.getName().startsWith("get") || method.getName().startsWith("is"))) { - properties.add(property); - getterProperties.put(property, method); - } - else if (method.getParameters().length == 1 && method.getName().startsWith("set")) { - properties.add(property); - setterProperties.put(property, method); - } - } - - this.properties = Collections.unmodifiableSet(properties); - this.getterProperties = Collections.unmodifiableMap(getterProperties); - this.setterProperties = Collections.unmodifiableMap(setterProperties); - } - - @Override - public String getBeanName() { - return Introspector.decapitalize(getName()); - } - - @Override - public Set getProperties() { - return properties; - } - - @Override - public MetaMethod getReadMethodForProperty(final String propertyName) { - return getterProperties.get(propertyName); - } - - @Override - public MetaMethod getWriteMethodForProperty(final String propertyName) { - return setterProperties.get(propertyName); - } - - @Override - public MetaClass getPropertyType(final String propertyName) { - final MetaMethod readMethod = getReadMethodForProperty(propertyName); - if (readMethod != null) { - return readMethod.getReturnType(); - } - - return getWriteMethodForProperty(propertyName).getParameters()[0].getType(); - } - }; - } - - @Override - public synchronized MetaClass getOuterComponentType() { - if (_outerComponentCache != null) - return _outerComponentCache; - - MetaClass c = this; - while (c.isArray()) { - c = c.getComponentType(); - } - return _outerComponentCache = c; - } - - private String contentString; - private int hashContent; - - @Override - public int hashContent() { - if (contentString == null) { - final StringBuilder sb = new StringBuilder(); - if (getAnnotations() != null) { - for (final Annotation a : getAnnotations()) { - sb.append(a.toString()); - } - } - for (final MetaMethod c : getDeclaredConstructors()) { - sb.append(c.toString()); - } - for (final MetaField f : getDeclaredFields()) { - sb.append(f.toString()); - } - for (final MetaMethod m : getDeclaredMethods()) { - sb.append(m.toString()); - } - for (final MetaClass i : getInterfaces()) { - sb.append(i.getFullyQualifiedNameWithTypeParms()); - } - for (final MetaClass dc : getDeclaredClasses()) { - sb.append(dc.getFullyQualifiedNameWithTypeParms()); - } - if (getSuperClass() != null) { - sb.append(getSuperClass().hashContent()); - } - - contentString = sb.toString(); - hashContent = contentString.hashCode(); - } - - return hashContent; - } - - private String _hashString; - static final private String MetaClassName = MetaClass.class.getName(); - - public String hashString() { - if (_hashString == null) { - _hashString = MetaClassName + ":" + getFullyQualifiedName(); - if (getParameterizedType() != null) { - _hashString += getParameterizedType().toString(); - } - } - return _hashString; - } - - private Integer _hashCode; - - @Override - public int hashCode() { - if (_hashCode != null) - return _hashCode; - return _hashCode = hashString().hashCode(); - } - - @Override - public boolean equals(final Object o) { - return o instanceof AbstractMetaClass && hashString().equals(((AbstractMetaClass) o).hashString()); - } - - @Override - public String toString() { - return getFullyQualifiedNameWithTypeParms(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/AbstractMetaParameterizedType.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/AbstractMetaParameterizedType.java deleted file mode 100644 index 03420693435..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/AbstractMetaParameterizedType.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta.impl; - -import java.util.Arrays; -import java.util.Collections; -import java.util.stream.Stream; - -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaParameterizedType; -import org.jboss.errai.codegen.meta.MetaType; -import org.jboss.errai.codegen.meta.MetaTypeVariable; -import org.jboss.errai.codegen.meta.MetaWildcardType; -import org.jboss.errai.common.client.api.Assert; - -/** - * @author Mike Brock - */ -public abstract class AbstractMetaParameterizedType implements MetaParameterizedType { - @Override - public boolean isAssignableFrom(final MetaParameterizedType fromType) { - final MetaType[] compareFrom = Assert.notNull(fromType).getTypeParameters(); - final MetaType[] compareTo = getTypeParameters(); - - if (compareTo.length != compareFrom.length) return false; - - for (int i = 0; i < compareTo.length; i++) { - final MetaType from = compareFrom[i]; - final MetaType to = compareTo[i]; - if (from instanceof MetaClass && to instanceof MetaClass) { - if (!((MetaClass) from).isAssignableTo((MetaClass) to)) { - return false; - } - } - else if (to instanceof MetaParameterizedType) { - return false; - } - else if (to instanceof MetaWildcardType) { - if (from instanceof MetaClass) { - final MetaClass fromMC = (MetaClass) from; - final boolean violatesUpperBound = getConcreteBounds(((MetaWildcardType) to).getUpperBounds()) - .filter(bound -> !fromMC.isAssignableTo(bound)) - .findAny() - .isPresent(); - final boolean violatesLowerBound = getConcreteBounds(((MetaWildcardType) to).getLowerBounds()) - .filter(bound -> !bound.isAssignableTo(fromMC)) - .findAny() - .isPresent(); - - if (violatesLowerBound || violatesUpperBound) { - return false; - } - } - else { - return false; - } - } - else if (from instanceof MetaTypeVariable && to instanceof MetaClass) { - final boolean hasAssignableUpperBound = getConcreteBounds(((MetaTypeVariable) from).getBounds()) - .filter(fromBound -> fromBound.isAssignableFrom((MetaClass) to)) - .findAny() - .isPresent(); - if (!hasAssignableUpperBound) { - return false; - } - } - } - - return true; - } - - private static Stream getConcreteBounds(final MetaType[] bounds) { - return Arrays - .stream(bounds) - .flatMap(bound -> { - if (bound instanceof MetaClass) { - return Collections.singletonList(bound).stream(); - } - else if (bound instanceof MetaTypeVariable) { - final MetaTypeVariable mtv = (MetaTypeVariable) bound; - return getConcreteBounds(mtv.getBounds()); - } - else { - return Collections.emptyList().stream(); - } - }).map(mt -> (MetaClass) mt); - } - - @Override - public final String toString() { - final StringBuilder buf = new StringBuilder("<"); - final MetaType[] parms = getTypeParameters(); - for (int i = 0; i < parms.length; i++) { - if (parms[i] instanceof MetaClass) { - buf.append(((MetaClass) parms[i]).getFullyQualifiedName()); - } - else { - buf.append(parms[i].toString()); - } - if (i + 1 < parms.length) buf.append(','); - } - return buf.append('>').toString(); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/AbstractMetaWildcardType.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/AbstractMetaWildcardType.java deleted file mode 100644 index 8fd159b61cd..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/AbstractMetaWildcardType.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta.impl; - -import org.jboss.errai.codegen.meta.MetaWildcardType; - -/** - * Base implementation for implementations of {@link MetaWildcardType}, - * providing uniform hashCode, equals, and toString implementations. - * - * @author Jonathan Fuerth - */ -public abstract class AbstractMetaWildcardType implements MetaWildcardType { - - @Override - public final String toString() { - return getName(); - } - - @Override - public final boolean equals(Object other) { - return other instanceof AbstractMetaWildcardType && - getName().equals(((AbstractMetaWildcardType) other).getName()); - } - - @Override - public final int hashCode() { - return getName().hashCode(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/build/BuildMetaClass.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/build/BuildMetaClass.java deleted file mode 100644 index f8a8b08bdde..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/build/BuildMetaClass.java +++ /dev/null @@ -1,855 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta.impl.build; - -import java.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -import com.google.common.collect.ObjectArrays; -import org.jboss.errai.codegen.BlockStatement; -import org.jboss.errai.codegen.Comment; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.DefParameters; -import org.jboss.errai.codegen.InnerClass; -import org.jboss.errai.codegen.Variable; -import org.jboss.errai.codegen.builder.Builder; -import org.jboss.errai.codegen.builder.callstack.LoadClassReference; -import org.jboss.errai.codegen.builder.impl.Scope; -import org.jboss.errai.codegen.literal.AnnotationLiteral; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.meta.MetaConstructor; -import org.jboss.errai.codegen.meta.MetaField; -import org.jboss.errai.codegen.meta.MetaMethod; -import org.jboss.errai.codegen.meta.MetaParameterizedType; -import org.jboss.errai.codegen.meta.MetaTypeVariable; -import org.jboss.errai.codegen.meta.impl.AbstractMetaClass; -import org.jboss.errai.codegen.util.GenUtil; -import org.jboss.errai.codegen.util.PrettyPrinter; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public class BuildMetaClass extends AbstractMetaClass implements Builder { - private Context context; - - private final String className; - private MetaClass superClass; - private List interfaces = new ArrayList<>(); - - private Scope scope; - - private boolean isArray; - private int dimensions; - private boolean isInterface; - private boolean isAbstract; - private boolean isFinal; - private boolean isStatic; - private boolean isInner; - - private final BlockStatement staticInitializer = new BlockStatement(); - private final BlockStatement instanceInitializer = new BlockStatement(); - - private List annotations = new ArrayList<>(); - private List innerClasses = new ArrayList<>(); - - private List methods = new ArrayList<>(); - private List fields = new ArrayList<>(); - private List constructors = new ArrayList<>(); - private List typeVariables = new ArrayList<>(); - private MetaClass reifiedFormOf; - - private String classComment; - - public BuildMetaClass(final Context context, final String name) { - super(null); - this.className = name; - if (context != null) { - this.context = Context.create(context); - this.context.addVariable(Variable.create("this", this)); - context.attachClass(this); - } - } - - private BuildMetaClass shallowCopy() { - final BuildMetaClass copy = new BuildMetaClass(context, className); - - copy.scope = scope; - copy.superClass = superClass; - copy.interfaces = interfaces; - - copy.isArray = isArray; - copy.dimensions = dimensions; - copy.isInterface = isInterface; - copy.isAbstract = isAbstract; - copy.isFinal = isFinal; - copy.isStatic = isStatic; - copy.isInner = isInner; - - copy.innerClasses = innerClasses; - copy.annotations = annotations; - copy.methods = methods; - copy.fields = fields; - copy.constructors = constructors; - copy.typeVariables = typeVariables; - copy.reifiedFormOf = reifiedFormOf; - - return copy; - } - - private BuildMetaClass _erasedCache; - - @Override - public MetaClass getErased() { - if (_erasedCache != null) { - return _erasedCache; - } - else if (typeVariables == null || typeVariables.isEmpty()) { - _erasedCache = this; - return _erasedCache; - } - else { - _erasedCache = shallowCopy(); - _erasedCache.typeVariables = Collections.emptyList(); - return _erasedCache; - } - } - - String _nameCache; - - @Override - public String getName() { - if (_nameCache != null) return _nameCache; - - final int idx = className.lastIndexOf('.'); - if (idx != -1) { - return _nameCache = className.substring(idx + 1); - } - else { - return _nameCache = className; - } - } - - @Override - public String getFullyQualifiedName() { - return className; - } - - @Override - public String getCanonicalName() { - return className; - } - - @Override - public String getInternalName() { - final String internalName = "L" + className.replace("\\.", "/") + ";"; - if (isArray) { - final StringBuilder buf = new StringBuilder(""); - for (int i = 0; i < dimensions; i++) { - buf.append("["); - } - return buf.append(internalName).toString(); - } - else { - return internalName; - } - } - - @Override - public String getPackageName() { - final int idx = className.lastIndexOf("."); - if (idx != -1) { - return className.substring(0, idx); - } - return ""; - } - - private MetaMethod[] _methodsCache; - - @Override - public MetaMethod[] getMethods() { - if (_methodsCache != null) return _methodsCache; - - final MetaMethod[] methodArray = methods.toArray(new MetaMethod[methods.size()]); - final MetaMethod[] outputMethods; - - if (superClass != null) { - final List methodList = new ArrayList<>(); - for (final MetaMethod m : superClass.getMethods()) { - if (_getMethod(methodArray, m.getName(), GenUtil.fromParameters(m.getParameters())) == null) { - methodList.add(m); - } - } - - methodList.addAll(Arrays.asList(methodArray)); - - outputMethods = methodList.toArray(new MetaMethod[methodList.size()]); - } - else { - outputMethods = methodArray; - } - - return _methodsCache = outputMethods; - } - - @Override - public MetaMethod[] getDeclaredMethods() { - return getMethods(); - } - - private MetaField[] _fieldsCache; - - @Override - public MetaField[] getFields() { - if (_fieldsCache == null) { - _fieldsCache = fields.stream().filter(field -> field.isPublic()).toArray(size -> new MetaField[size]); - if (superClass != null) { - _fieldsCache = ObjectArrays.concat(_fieldsCache, superClass.getFields(), MetaField.class); - } - } - return _fieldsCache; - } - - private MetaField[] _declaredFieldsCache; - - @Override - public MetaField[] getDeclaredFields() { - if (_declaredFieldsCache == null) { - _declaredFieldsCache = fields.toArray(new MetaField[fields.size()]); - } - - return _declaredFieldsCache; - } - - @Override - public MetaField getField(final String name) { - return fields.stream().filter(f -> f.getName().equals(name)).findFirst().orElse(null); - } - - @Override - public MetaField getDeclaredField(final String name) { - return getField(name); - } - - private MetaConstructor[] _constructorsCache; - - @Override - public MetaConstructor[] getConstructors() { - if (_constructorsCache != null) return _constructorsCache; - - if (constructors.isEmpty()) { - // add an empty no-arg constructor - final BuildMetaConstructor buildMetaConstructor = - new BuildMetaConstructor(this, new BlockStatement(), DefParameters.none()); - - buildMetaConstructor.setScope(Scope.Public); - return _constructorsCache = new MetaConstructor[]{buildMetaConstructor}; - } - else { - return _constructorsCache = constructors.toArray(new MetaConstructor[constructors.size()]); - } - } - - @Override - public MetaConstructor[] getDeclaredConstructors() { - return getConstructors(); - } - - - @Override - public MetaClass[] getDeclaredClasses() { - final MetaClass[] declaredClass = new MetaClass[innerClasses.size()]; - int i = 0; - for (final InnerClass innerClass : innerClasses) { - declaredClass[i++] = innerClass.getType(); - } - return declaredClass; - } - - @Override - public MetaClass[] getInterfaces() { - return interfaces.toArray(new MetaClass[interfaces.size()]); - } - - @Override - public MetaClass getSuperClass() { - return superClass; - } - - @Override - public MetaClass getComponentType() { - if (isArray) { - final BuildMetaClass compType = shallowCopy(); - if (dimensions > 1) { - compType.setDimensions(dimensions - 1); - } - else { - compType.setArray(false); - compType.setDimensions(0); - } - - return compType; - } - return null; - } - - @Override - public boolean isPrimitive() { - return false; - } - - @Override - public boolean isVoid() { - return false; - } - - @Override - public boolean isInterface() { - return isInterface; - } - - @Override - public boolean isAbstract() { - return isAbstract; - } - - @Override - public boolean isArray() { - return false; - } - - @Override - public boolean isEnum() { - return false; - } - - @Override - public boolean isAnnotation() { - return false; - } - - @Override - public boolean isPublic() { - return scope == Scope.Public; - } - - @Override - public boolean isPrivate() { - return scope == Scope.Private; - } - - @Override - public boolean isProtected() { - return scope == Scope.Protected; - } - - @Override - public boolean isFinal() { - return isFinal; - } - - @Override - public boolean isStatic() { - return isStatic; - } - - @Override - public boolean isSynthetic() { - return false; - } - - @Override - public boolean isAnonymousClass() { - return false; - } - - @Override - public Annotation[] getAnnotations() { - return annotations.toArray(new Annotation[annotations.size()]); - } - - @Override - public MetaTypeVariable[] getTypeParameters() { - return typeVariables.toArray(new MetaTypeVariable[typeVariables.size()]); - } - - public void setSuperClass(final MetaClass superClass) { - this.superClass = superClass; - } - - public void setInterfaces(final List interfaces) { - this.interfaces = interfaces; - } - - public void setInterface(final boolean anInterface) { - isInterface = anInterface; - } - - public void setAbstract(final boolean anAbstract) { - isAbstract = anAbstract; - } - - public void setArray(final boolean array) { - isArray = array; - } - - public void setDimensions(final int dimensions) { - this.dimensions = dimensions; - } - - public int getDimensions() { - return dimensions; - } - - public void setFinal(final boolean aFinal) { - isFinal = aFinal; - } - - public void setStatic(final boolean aStatic) { - isStatic = aStatic; - } - - public void setInner(final boolean aInner) { - isInner = aInner; - } - - public void setScope(final Scope scope) { - this.scope = scope; - } - - public void setContext(final Context context) { - this.context = context; - } - - public Context getContext() { - return context; - } - - public void addAnnotation(final Annotation annotation) { - annotations.add(annotation); - } - - public void addInnerClass(final InnerClass innerClass) { - innerClasses.add(innerClass); - } - - public void addInterface(final MetaClass interfaceClass) { - interfaces.add(interfaceClass); - } - - public void addConstructor(final BuildMetaConstructor constructor) { - _constructorsCache = null; - constructors.add(constructor); - } - - public void addMethod(final BuildMetaMethod method) { - _methodsCache = null; - - methods.add(method); - } - - public void addField(final BuildMetaField field) { - _fieldsCache = null; - - if (getDeclaredField(field.getName()) != null) { - throw new IllegalStateException("field '" + field.getName() + "' already exists"); - } - - fields.add(field); - } - - public void addTypeVariable(final MetaTypeVariable typeVariable) { - typeVariables.add(typeVariable); - } - - public void setParameterizedType(final MetaParameterizedType parameterizedType) { - this.parameterizedType = parameterizedType; - } - - public boolean isReifiedForm() { - return reifiedFormOf != null; - } - - public MetaClass getReifiedFormOf() { - return reifiedFormOf; - } - - public void setReifiedFormOf(final MetaClass reifiedFormOf) { - this.reifiedFormOf = reifiedFormOf; - } - - @Override - public MetaMethod getBestMatchingMethod(final String name, final Class... parameters) { - return super.getBestMatchingMethod(name, parameters); - } - - @Override - public MetaMethod getBestMatchingMethod(final String name, final MetaClass... parameters) { - return super.getBestMatchingMethod(name, parameters); - } - - @Override - public MetaMethod getBestMatchingStaticMethod(final String name, final Class... parameters) { - return super.getBestMatchingStaticMethod(name, parameters); - } - - @Override - public MetaMethod getBestMatchingStaticMethod(final String name, final MetaClass... parameters) { - return super.getBestMatchingStaticMethod(name, parameters); - } - - @Override - public MetaConstructor getBestMatchingConstructor(final Class... parameters) { - return super.getBestMatchingConstructor(parameters); - } - - @Override - public MetaConstructor getBestMatchingConstructor(final MetaClass... parameters) { - return super.getBestMatchingConstructor(parameters); - } - - @Override - public MetaClass asArrayOf(final int dimensions) { - final BuildMetaClass copy = shallowCopy(); - copy.setArray(true); - copy.setDimensions(dimensions); - return copy; - } - - public void setClassComment(final String classComment) { - this.classComment = classComment; - } - - public BlockStatement getStaticInitializer() { - return staticInitializer; - } - - public BlockStatement getInstanceInitializer() { - return instanceInitializer; - } - - String generatedCache; - - @Override - public String toJavaString() { - return toJavaString(this.context); - } - - public String toJavaString(final Context context) { - if (context == null) { - throw new IllegalArgumentException("Cannot generate Java String with null Context."); - } - - if (generatedCache != null) return generatedCache; - - final StringBuilder buf = new StringBuilder(512); - - if (classComment != null) { - buf.append(new Comment(classComment).generate(null)).append("\n"); - } - - context.addVariable(Variable.create("this", this)); - - MetaClass sCls = getSuperClass(); - if (sCls != null) { - do { - for (final MetaField metaField : sCls.getDeclaredFields()) { - if (!metaField.isPrivate()) { - context.addVariable(Variable.create(metaField.getName(), metaField.getType())); - } - } - } while ((sCls = sCls.getSuperClass()) != null && !sCls.getName().equals("java.lang.Object")); - } - - for (final BuildMetaField buildMetaField : fields) { - context.addVariable(Variable.create(buildMetaField.getName(), buildMetaField.getType())); - } - - for (final Annotation a : getAnnotations()) { - buf.append(new AnnotationLiteral(a).getCanonicalString(context)); - buf.append(" "); - } - - if (!annotations.isEmpty()) buf.append("\n"); - - buf.append("\n"); - - buf.append(scope.getCanonicalName()); - - if (isAbstract) { - buf.append(" abstract"); - } - - if (isStatic) { - buf.append(" static"); - } - - if (isInterface()) { - buf.append(" interface ").append(getName()); - } - else { - buf.append(" class ").append(getName()); - } - - final List interfacesToRender = new ArrayList<>(interfaces.size() + 1); - interfacesToRender.addAll(interfaces); - - if (getSuperClass() != null) { - if (isInterface()) { - interfacesToRender.add(getSuperClass()); - } - else { - buf.append(" extends ").append(LoadClassReference.getClassReference(getSuperClass(), context)); - } - } - - if (!interfacesToRender.isEmpty()) { - if (isInterface()) { - buf.append(" extends "); - } - else { - buf.append(" implements "); - } - - final Iterator metaClassIterator = interfacesToRender.iterator(); - while (metaClassIterator.hasNext()) { - buf.append(LoadClassReference.getClassReference(metaClassIterator.next(), context)); - if (metaClassIterator.hasNext()) - buf.append(", "); - } - } - - superClass = (superClass != null) ? superClass : MetaClassFactory.get(Object.class); - context.addVariable(Variable.create("super", superClass)); - - buf.append(" {"); - - if (!staticInitializer.isEmpty()) { - buf.append("\nstatic {\n"); - buf.append(staticInitializer.generate(context)); - buf.append("\n}"); - } - - if (!instanceInitializer.isEmpty()) { - buf.append("\n{\n"); - buf.append(instanceInitializer.generate(context)); - buf.append("\n}\n"); - } - - buf.append(membersToString()); - - final StringBuilder headerBuffer = new StringBuilder(128); - - if (!getPackageName().isEmpty() && !isInner) - headerBuffer.append("package ").append(getPackageName()).append(";\n"); - - if (!context.getRequiredImports().isEmpty()) - headerBuffer.append("\n"); - - if (!isInner) { - for (final String cls : context.getRequiredImports()) { - if (getFullyQualifiedName().equals(cls)) { - continue; - } - else { - final String pkg = getPackageName(); - if (cls.startsWith(pkg)) { - if (cls.substring(pkg.length() + 1).indexOf('.') == -1) { - continue; - } - } - } - - headerBuffer.append("import ").append(cls).append(";\n"); - } - } - - return generatedCache = PrettyPrinter.prettyPrintJava(headerBuffer.toString() + buf.append("}\n").toString()); - } - - private List diffList(final List original, - final List against) { - - final List copyList = new ArrayList<>(original); - copyList.removeAll(against); - return copyList; - } - - public String membersToString() { - if (context == null) { - throw new IllegalStateException("Cannot call membersToString when no context is set."); - } - - final StringBuilder buf = new StringBuilder(512); - - final Iterator innerClassIterator = innerClasses.iterator(); - while (innerClassIterator.hasNext()) { - buf.append(innerClassIterator.next().generate(context)); - if (innerClassIterator.hasNext()) buf.append("\n"); - } - - if (!innerClasses.isEmpty()) - buf.append("\n"); - - final Iterator constructorIterator = constructors.iterator(); - while (constructorIterator.hasNext()) { - buf.append(constructorIterator.next().toJavaString()); - if (constructorIterator.hasNext()) - buf.append("\n"); - } - - if (!constructors.isEmpty()) - buf.append("\n"); - - final Iterator methodsIterator = methods.iterator(); - while (methodsIterator.hasNext()) { - buf.append(methodsIterator.next().toJavaString()); - if (methodsIterator.hasNext()) - buf.append("\n"); - } - - final StringBuilder fieldRenderBuffer = renderFieldBuffer(); - - if (!fields.isEmpty()) { - return fieldRenderBuffer.toString() + buf.toString(); - } else { - return buf.toString(); - } - } - - private StringBuilder renderFieldBuffer() { - List toBuild = new ArrayList<>(fields); - final List toIterate = new ArrayList<>(toBuild); - - int initialFieldSize; - - final boolean _permissiveMode = GenUtil.isPermissiveMode(); - GenUtil.setPermissiveMode(true); - final StringBuilder fieldRenderBuffer = new StringBuilder(100); - final int bufferStart; - - if (!fields.isEmpty()) { - fieldRenderBuffer.append('\n'); - bufferStart = 1; - } else { - bufferStart = 0; - } - - do { - initialFieldSize = fields.size(); - - if (fieldRenderBuffer.length() > 0) { - fieldRenderBuffer.delete(bufferStart, fieldRenderBuffer.length()); - } - - final Iterator fieldIterator = toIterate.iterator(); - while (fieldIterator.hasNext()) { - fieldRenderBuffer.append(fieldIterator.next().toJavaString()); - if (fieldIterator.hasNext()) - fieldRenderBuffer.append("\n"); - } - - toIterate.addAll(0, diffList(fields, toBuild)); - toBuild = new ArrayList<>(fields); - } - while (initialFieldSize < fields.size()); - - if (!fields.isEmpty()) { - fieldRenderBuffer.append('\n'); - } - - GenUtil.setPermissiveMode(_permissiveMode); - - if (!_permissiveMode) { - toBuild.stream().forEach(builder -> builder.toJavaString()); - } - return fieldRenderBuffer; - } - - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (!(o instanceof BuildMetaClass)) return false; - if (!super.equals(o)) return false; - - final BuildMetaClass that = (BuildMetaClass) o; - - if (dimensions != that.dimensions) return false; - if (isAbstract != that.isAbstract) return false; - if (isArray != that.isArray) return false; - if (isFinal != that.isFinal) return false; - if (isInner != that.isInner) return false; - if (isInterface != that.isInterface) return false; - if (isStatic != that.isStatic) return false; - if (!Arrays.equals(_constructorsCache, that._constructorsCache)) return false; - if (!Arrays.equals(_fieldsCache, that._fieldsCache)) return false; - if (!Arrays.equals(_methodsCache, that._methodsCache)) return false; - if (_nameCache != null ? !_nameCache.equals(that._nameCache) : that._nameCache != null) return false; - if (className != null ? !className.equals(that.className) : that.className != null) return false; - if (constructors != null ? !constructors.equals(that.constructors) : that.constructors != null) return false; - if (context != null ? !context.equals(that.context) : that.context != null) return false; - if (fields != null ? !fields.equals(that.fields) : that.fields != null) return false; - if (generatedCache != null ? !generatedCache.equals(that.generatedCache) : that.generatedCache != null) - return false; - if (interfaces != null ? !interfaces.equals(that.interfaces) : that.interfaces != null) return false; - if (methods != null ? !methods.equals(that.methods) : that.methods != null) return false; - if (reifiedFormOf != null ? !reifiedFormOf.equals(that.reifiedFormOf) : that.reifiedFormOf != null) return false; - if (scope != that.scope) return false; - if (superClass != null ? !superClass.equals(that.superClass) : that.superClass != null) return false; - if (typeVariables != null ? !typeVariables.equals(that.typeVariables) : that.typeVariables != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + (context != null ? context.hashCode() : 0); - result = 31 * result + (className != null ? className.hashCode() : 0); - result = 31 * result + (superClass != null ? superClass.hashCode() : 0); - result = 31 * result + (interfaces != null ? interfaces.hashCode() : 0); - result = 31 * result + (scope != null ? scope.hashCode() : 0); - result = 31 * result + (isArray ? 1 : 0); - result = 31 * result + dimensions; - result = 31 * result + (isInterface ? 1 : 0); - result = 31 * result + (isAbstract ? 1 : 0); - result = 31 * result + (isFinal ? 1 : 0); - result = 31 * result + (isStatic ? 1 : 0); - result = 31 * result + (isInner ? 1 : 0); - result = 31 * result + (methods != null ? methods.hashCode() : 0); - result = 31 * result + (fields != null ? fields.hashCode() : 0); - result = 31 * result + (constructors != null ? constructors.hashCode() : 0); - result = 31 * result + (typeVariables != null ? typeVariables.hashCode() : 0); - result = 31 * result + (reifiedFormOf != null ? reifiedFormOf.hashCode() : 0); - result = 31 * result + (_nameCache != null ? _nameCache.hashCode() : 0); - result = 31 * result + (_methodsCache != null ? Arrays.hashCode(_methodsCache) : 0); - result = 31 * result + (_fieldsCache != null ? Arrays.hashCode(_fieldsCache) : 0); - result = 31 * result + (_constructorsCache != null ? Arrays.hashCode(_constructorsCache) : 0); - result = 31 * result + (generatedCache != null ? generatedCache.hashCode() : 0); - return result; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/build/BuildMetaConstructor.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/build/BuildMetaConstructor.java deleted file mode 100644 index 1bdf905af05..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/build/BuildMetaConstructor.java +++ /dev/null @@ -1,292 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta.impl.build; - -import java.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.List; - -import org.jboss.errai.codegen.Comment; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.DefParameters; -import org.jboss.errai.codegen.Parameter; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.Variable; -import org.jboss.errai.codegen.builder.Builder; -import org.jboss.errai.codegen.builder.impl.Scope; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassMember; -import org.jboss.errai.codegen.meta.MetaConstructor; -import org.jboss.errai.codegen.meta.MetaParameter; -import org.jboss.errai.codegen.meta.MetaType; -import org.jboss.errai.codegen.meta.MetaTypeVariable; -import org.jboss.errai.codegen.util.GenUtil; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public class BuildMetaConstructor extends MetaConstructor implements Builder { - private final BuildMetaClass declaringClass; - private Statement body; - - private boolean isVarArgs; - private boolean isAbstract; - private Scope scope; - - private DefParameters defParameters; - private final List typeVariables = new ArrayList(); - - private MetaConstructor reifiedFormOf; - - private String constructorComment; - - public BuildMetaConstructor(final BuildMetaClass declaringClass) { - this.declaringClass = declaringClass; - } - - public BuildMetaConstructor(final BuildMetaClass declaringClass, - final Statement body) { - this.declaringClass = declaringClass; - this.body = body; - } - - public BuildMetaConstructor(final BuildMetaClass declaringClass, - final Statement body, - final DefParameters defParameters) { - this(declaringClass, body); - this.defParameters = defParameters; - } - - public BuildMetaConstructor(final BuildMetaClass declaringClass, - final Statement body, - final Scope scope, - final DefParameters defParameters) { - this(declaringClass, body, defParameters); - this.scope = scope; - } - - @Override - public MetaParameter[] getParameters() { - if (defParameters == null) { - return new MetaParameter[0]; - } - else { - final List metaParameterList = new ArrayList(); - for (final Parameter p : defParameters.getParameters()) { - - metaParameterList.add(new MetaParameter() { - @Override - public String getName() { - return p.getName(); - } - - @Override - public MetaClass getType() { - return p.getType(); - } - - @Override - public MetaClassMember getDeclaringMember() { - return BuildMetaConstructor.this; - } - - @Override - public Annotation[] getAnnotations() { - return new Annotation[0]; - } - - @Override - public boolean isAnnotationPresent(final Class annotation) { - return false; - } - - @Override - public A getAnnotation(final Class annotation) { - return null; - } - }); - } - return metaParameterList.toArray(new MetaParameter[metaParameterList.size()]); - } - } - - @Override - public MetaType[] getGenericParameterTypes() { - return typeVariables.toArray(new MetaTypeVariable[typeVariables.size()]); - } - - @Override - public boolean isVarArgs() { - return isVarArgs; - } - - @Override - public MetaClass getDeclaringClass() { - return declaringClass; - } - - @Override - public String getDeclaringClassName() { - return declaringClass.getName(); - } - - @Override - public boolean isAbstract() { - return isAbstract; - } - - @Override - public boolean isPublic() { - return scope == Scope.Public; - } - - @Override - public boolean isPrivate() { - return scope == Scope.Private; - } - - @Override - public boolean isProtected() { - return scope == Scope.Protected; - } - - @Override - public boolean isFinal() { - return false; - } - - @Override - public boolean isStatic() { - return true; - } - - @Override - public boolean isTransient() { - return false; - } - - @Override - public boolean isSynthetic() { - return false; - } - - @Override - public boolean isVolatile() { - return false; - } - - @Override - public boolean isSynchronized() { - return false; - } - - public void setScope(final Scope scope) { - this.scope = scope; - } - - @Override - public Annotation[] getAnnotations() { - return new Annotation[0]; - } - - @Override - public MetaTypeVariable[] getTypeParameters() { - return typeVariables.toArray(new MetaTypeVariable[typeVariables.size()]); - } - - public Statement getBody() { - return body; - } - - public void setBody(final Statement body) { - this.body = body; - } - - public void setDefParameters(final DefParameters defParameters) { - this.defParameters = defParameters; - } - - - @Override - public MetaClass[] getCheckedExceptions() { - return new MetaClass[0]; - } - - @Override - public String getName() { - return ""; - } - - @Override - public MetaClass getReturnType() { - return this.declaringClass; - } - - @Override - public MetaType getGenericReturnType() { - return this.declaringClass; - } - - public boolean isReifiedForm() { - return reifiedFormOf != null; - } - - public MetaConstructor getReifiedFormOf() { - return reifiedFormOf; - } - - public void setReifiedFormOf(final MetaConstructor reifiedFormOf) { - this.reifiedFormOf = reifiedFormOf; - } - - public void setConstructorComment(final String constructorComment) { - this.constructorComment = constructorComment; - } - - String generatedCache; - - @Override - public String toJavaString() { - if (generatedCache != null) return generatedCache; - - final Context context = Context.create(declaringClass.getContext()); - defParameters.getParameters().stream().forEach(p -> context.addVariable(Variable.create(p.getName(), p.getType()))); - - final StringBuilder build = new StringBuilder(512); - if (constructorComment != null) { - build.append(new Comment(constructorComment).generate(null)).append('\n'); - } - - return generatedCache = - build.append(scope.getCanonicalName()) - .append(" ") - .append(declaringClass.getName()) - .append(defParameters.generate(context)) - .append(" {\n").append(body.generate(context)).append("\n}\n") - .toString(); - } - - @Override - public boolean equals(final Object o) { - return o instanceof MetaConstructor && GenUtil.equals(this, (MetaConstructor) o); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/build/BuildMetaField.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/build/BuildMetaField.java deleted file mode 100644 index bdbd20a02cd..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/build/BuildMetaField.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta.impl.build; - -import java.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.List; - -import org.jboss.errai.codegen.Comment; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.Variable; -import org.jboss.errai.codegen.builder.Builder; -import org.jboss.errai.codegen.builder.impl.Scope; -import org.jboss.errai.codegen.literal.AnnotationLiteral; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaField; -import org.jboss.errai.codegen.meta.MetaType; - -/** - * @author Mike Brock - */ -public class BuildMetaField extends MetaField implements Builder { - private BuildMetaClass declaringClass; - private Statement statement; - - private Scope scope; - - private MetaClass type; - private MetaType genericType; - private String name; - - private boolean isFinal; - private boolean isStatic; - private boolean isTransient; - private boolean isVolatile; - - private String fieldComment; - - private final List annotations = new ArrayList(); - - - public BuildMetaField(BuildMetaClass declaringClass, Statement statement, Scope scope, MetaClass type, String name) { - this.declaringClass = declaringClass; - this.statement = statement; - this.scope = scope; - this.type = type; - this.name = name; - } - - @Override - public MetaClass getType() { - return type; - } - - @Override - public MetaType getGenericType() { - return genericType; - } - - @Override - public String getName() { - return name; - } - - @Override - public Annotation[] getAnnotations() { - return annotations.toArray(new Annotation[annotations.size()]); - } - - @Override - public MetaClass getDeclaringClass() { - return declaringClass; - } - - @Override - public String getDeclaringClassName() { - return declaringClass.getName(); - } - - @Override - public boolean isAbstract() { - return false; - } - - @Override - public boolean isPublic() { - return scope == Scope.Public; - } - - @Override - public boolean isPrivate() { - return scope == Scope.Private; - } - - @Override - public boolean isProtected() { - return scope == Scope.Protected; - } - - @Override - public boolean isFinal() { - return isFinal; - } - - @Override - public boolean isStatic() { - return isStatic; - } - - @Override - public boolean isTransient() { - return isTransient; - } - - @Override - public boolean isSynthetic() { - return false; - } - - @Override - public boolean isVolatile() { - return isVolatile; - } - - @Override - public boolean isSynchronized() { - return false; - } - - public void setDeclaringClass(BuildMetaClass declaringClass) { - this.declaringClass = declaringClass; - } - - public void setScope(Scope scope) { - this.scope = scope; - } - - public void setType(MetaClass type) { - this.type = type; - } - - public void setGenericType(MetaType genericType) { - this.genericType = genericType; - } - - public void setName(String name) { - this.name = name; - } - - public void setFinal(boolean aFinal) { - isFinal = aFinal; - } - - public void setStatic(boolean aStatic) { - isStatic = aStatic; - } - - public void setTransient(boolean aTransient) { - isTransient = aTransient; - } - - public void setVolatile(boolean aVolatile) { - isVolatile = aVolatile; - } - - public void addAnnotation(Annotation annotation) { - annotations.add(annotation); - } - - public void setStatement(Statement statement) { - this.statement = statement; - } - - public void setFieldComment(String fieldComment) { - this.fieldComment = fieldComment; - } - - @Override - public String toJavaString() { - final StringBuilder builder = new StringBuilder(25); - if (fieldComment != null) { - builder.append(new Comment(fieldComment).generate(null)).append('\n'); - } - - if (!annotations.isEmpty()) { - for (final Annotation a : getAnnotations()) { - builder.append(new AnnotationLiteral(a).getCanonicalString(Context.create())).append(" "); - } - } - - declaringClass.getContext().addVariable(Variable.create(name, type)); - - builder.append(statement.generate(declaringClass.getContext())); - - return builder.toString(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/build/BuildMetaMethod.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/build/BuildMetaMethod.java deleted file mode 100644 index 7649b0a952e..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/build/BuildMetaMethod.java +++ /dev/null @@ -1,358 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta.impl.build; - -import java.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; - -import org.jboss.errai.codegen.BlockStatement; -import org.jboss.errai.codegen.Comment; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.DefModifiers; -import org.jboss.errai.codegen.DefParameters; -import org.jboss.errai.codegen.Modifier; -import org.jboss.errai.codegen.Parameter; -import org.jboss.errai.codegen.ThrowsDeclaration; -import org.jboss.errai.codegen.Variable; -import org.jboss.errai.codegen.builder.Builder; -import org.jboss.errai.codegen.builder.callstack.LoadClassReference; -import org.jboss.errai.codegen.builder.impl.Scope; -import org.jboss.errai.codegen.literal.AnnotationLiteral; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassMember; -import org.jboss.errai.codegen.meta.MetaMethod; -import org.jboss.errai.codegen.meta.MetaParameter; -import org.jboss.errai.codegen.meta.MetaType; -import org.jboss.errai.codegen.meta.MetaTypeVariable; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public class BuildMetaMethod extends MetaMethod implements Builder { - private BuildMetaClass declaringClass; - private BlockStatement body; - - private Scope scope; - private final DefModifiers modifiers; - - private String name; - private MetaClass returnType; - private DefParameters defParameters; - - private List genericParameterTypes; - - private ThrowsDeclaration throwsDeclaration; - - private MetaMethod reifiedFormOf; - - private final List annotations = new ArrayList(); - - private String methodComment; - - public BuildMetaMethod(final BuildMetaClass declaringClass, - final BlockStatement body, - final Scope scope, - final DefModifiers modifiers, - final String name, - final MetaClass returnType, - final DefParameters defParameters, - final ThrowsDeclaration throwsDeclaration - ) { - - this.declaringClass = declaringClass; - this.body = body; - this.modifiers = modifiers; - this.scope = scope; - this.name = name; - this.returnType = returnType; - this.defParameters = defParameters; - this.throwsDeclaration = throwsDeclaration; - } - - @Override - public String getName() { - return name; - } - - @Override - public MetaClass getReturnType() { - return returnType; - } - - // don't try to support this for now. - @Override - public MetaType getGenericReturnType() { - return null; - } - - @Override - public MetaType[] getGenericParameterTypes() { - if (genericParameterTypes == null) - return new MetaType[0]; - - return genericParameterTypes.toArray(new MetaType[genericParameterTypes.size()]); - } - - @Override - public MetaParameter[] getParameters() { - final List parameters = defParameters.getParameters(); - if (parameters != null) { - final List metaParameterList = new ArrayList(); - for (final Parameter p : parameters) { - metaParameterList.add(new MetaParameter() { - @Override - public String getName() { - return p.getName(); - } - - @Override - public MetaClass getType() { - return p.getType(); - } - - @Override - public MetaClassMember getDeclaringMember() { - return BuildMetaMethod.this; - } - - @Override - public Annotation[] getAnnotations() { - return new Annotation[0]; - } - - @Override - public boolean isAnnotationPresent(final Class annotation) { - return false; - } - - @Override - public A getAnnotation(final Class annotation) { - return null; - } - }); - } - - return metaParameterList.toArray(new MetaParameter[metaParameterList.size()]); - } - else { - return new MetaParameter[0]; - } - } - - @Override - public MetaClass getDeclaringClass() { - return declaringClass; - } - - @Override - public String getDeclaringClassName() { - return declaringClass.getName(); - } - - @Override - public boolean isAbstract() { - return modifiers.hasModifier(Modifier.Abstract); - } - - @Override - public boolean isPublic() { - return scope == Scope.Public; - } - - @Override - public boolean isPrivate() { - return scope == Scope.Private; - } - - @Override - public boolean isProtected() { - return scope == Scope.Protected; - } - - @Override - public boolean isFinal() { - return modifiers.hasModifier(Modifier.Final); - } - - @Override - public boolean isStatic() { - return modifiers.hasModifier(Modifier.Static); - } - - @Override - public boolean isTransient() { - return false; - } - - @Override - public boolean isSynthetic() { - return false; - } - - @Override - public boolean isVolatile() { - return false; - } - - @Override - public boolean isSynchronized() { - return modifiers.hasModifier(Modifier.Synchronized); - } - - public void addAnnotations(final Annotation... annotations) { - addAnnotations(Arrays.asList(annotations)); - } - - public void addAnnotations(final Collection annotations) { - annotations.forEach(a -> this.annotations.add(a)); - } - - @Override - public Annotation[] getAnnotations() { - return annotations.toArray(new Annotation[annotations.size()]); - } - - @Override - public MetaTypeVariable[] getTypeParameters() { - return new MetaTypeVariable[0]; - } - - @Override - public MetaClass[] getCheckedExceptions() { - return throwsDeclaration.getExceptionTypes(); - } - - public void setDeclaringClass(final BuildMetaClass declaringClass) { - this.declaringClass = declaringClass; - } - - public void setScope(final Scope scope) { - this.scope = scope; - } - - public void setName(final String name) { - this.name = name; - } - - public void setReturnType(final MetaClass returnType) { - this.returnType = returnType; - } - - public void setGenericReturnType(final MetaType genericReturnType) { - // this.genericReturnType = genericReturnType; - } - - public void setGenericParameterTypes(final List genericParameterTypes) { - this.genericParameterTypes = genericParameterTypes; - } - - public void setBody(final BlockStatement body) { - this.body = body; - } - - public void setDefParameters(final DefParameters defParameters) { - this.defParameters = defParameters; - } - - public void setThrowsDeclaration(final ThrowsDeclaration throwsDeclaration) { - this.throwsDeclaration = throwsDeclaration; - } - - public BlockStatement getBody() { - return body; - } - - @Override - public boolean isVarArgs() { - return false; - } - - public boolean isReifiedForm() { - return reifiedFormOf != null; - } - - public MetaMethod getReifiedFormOf() { - return reifiedFormOf; - } - - public void setReifiedFormOf(final MetaMethod reifiedFormOf) { - this.reifiedFormOf = reifiedFormOf; - } - - public void setMethodComment(final String methodComment) { - this.methodComment = methodComment; - } - - @Override - public String toJavaString() { - final Context context = Context.create(declaringClass.getContext()); - - for (final Parameter p : defParameters.getParameters()) { - context.addVariable(Variable.create(p.getName(), p.getType())); - } - final StringBuilder buf = new StringBuilder(256); - - if (!annotations.isEmpty()) { - for (final Annotation a : getAnnotations()) { - buf.append(new AnnotationLiteral(a).getCanonicalString(context)).append(" "); - } - buf.append("\n"); - } - - if (methodComment != null) { - buf.append(new Comment(methodComment).generate(null)).append("\n"); - } - - buf.append(scope.getCanonicalName()).append(" ") - .append(modifiers.toJavaString()).append(" "); - - buf.append(LoadClassReference.getClassReference(returnType, context, false)) - .append(" ") - .append(name) - .append(defParameters.generate(context)); - - if (!throwsDeclaration.isEmpty()) { - buf.append(" ") - .append(throwsDeclaration.generate(context)); - } - - if (modifiers.hasModifier(Modifier.Abstract) || getDeclaringClass().isInterface()) { - buf.append(";"); - } - else if (modifiers.hasModifier(Modifier.JSNI)) { - buf.append(" /*-{\n").append(body.generate(context)).append("\n}-*/;\n"); - } - else { - buf.append(" {\n").append(body.generate(context)).append("\n}\n"); - } - - return buf.toString(); - } - - @Override - public String toString() { - return name + defParameters; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/build/BuildMetaParameterizedType.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/build/BuildMetaParameterizedType.java deleted file mode 100644 index 46acefc8bb7..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/build/BuildMetaParameterizedType.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta.impl.build; - -import org.jboss.errai.codegen.meta.MetaType; -import org.jboss.errai.codegen.meta.impl.AbstractMetaParameterizedType; - -/** - * @author Mike Brock - */ -public class BuildMetaParameterizedType extends AbstractMetaParameterizedType { - private final MetaType[] types; - private final MetaType ownerType; - private final MetaType rawType; - - public BuildMetaParameterizedType(MetaType[] types, MetaType ownerType, MetaType rawType) { - this.types = types; - this.ownerType = ownerType; - this.rawType = rawType; - } - - @Override - public MetaType[] getTypeParameters() { - return types; - } - - @Override - public MetaType getOwnerType() { - return ownerType; - } - - @Override - public MetaType getRawType() { - return rawType; - } - - @Override - public String getName() { - return ownerType.getName(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/build/ShadowBuildMetaField.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/build/ShadowBuildMetaField.java deleted file mode 100644 index b79722a81b5..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/build/ShadowBuildMetaField.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta.impl.build; - -import java.lang.reflect.Field; - -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.builder.impl.Scope; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaField; - -/** - * @author Mike Brock - */ -public class ShadowBuildMetaField extends BuildMetaField { - private MetaField shadow; - - public ShadowBuildMetaField(BuildMetaClass declaringClass, Statement statement, Scope scope, MetaClass type, String name, MetaField shadow) { - super(declaringClass, statement, scope, type, name); - this.shadow = shadow; - } - - - @Override - public Field asField() { - return shadow.asField(); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/build/ShadowBuildMetaMethod.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/build/ShadowBuildMetaMethod.java deleted file mode 100644 index 627765444cb..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/build/ShadowBuildMetaMethod.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta.impl.build; - -import java.lang.reflect.Method; - -import org.jboss.errai.codegen.BlockStatement; -import org.jboss.errai.codegen.DefModifiers; -import org.jboss.errai.codegen.DefParameters; -import org.jboss.errai.codegen.ThrowsDeclaration; -import org.jboss.errai.codegen.builder.impl.Scope; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaMethod; - -/** - * @author Mike Brock - */ -public class ShadowBuildMetaMethod extends BuildMetaMethod { - private MetaMethod shadow; - - public ShadowBuildMetaMethod(BuildMetaClass declaringClass, BlockStatement body, Scope scope, DefModifiers modifiers, String name, - MetaClass returnType, DefParameters defParameters, - ThrowsDeclaration throwsDeclaration, MetaMethod shadow) { - super(declaringClass, body, scope, modifiers, name, returnType, defParameters, throwsDeclaration); - this.shadow = shadow; - } - - @Override - public Method asMethod() { - return shadow.asMethod(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/java/JavaReflectionClass.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/java/JavaReflectionClass.java deleted file mode 100644 index 94cddb93b7c..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/java/JavaReflectionClass.java +++ /dev/null @@ -1,472 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta.impl.java; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.enterprise.util.TypeLiteral; - -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.meta.MetaConstructor; -import org.jboss.errai.codegen.meta.MetaField; -import org.jboss.errai.codegen.meta.MetaMethod; -import org.jboss.errai.codegen.meta.MetaTypeVariable; -import org.jboss.errai.codegen.meta.impl.AbstractMetaClass; -import org.jboss.errai.codegen.util.GenUtil; - -import static org.jboss.errai.codegen.meta.MetaClassFactory.parameterizedAs; -import static org.jboss.errai.codegen.meta.MetaClassFactory.typeParametersOf; - -public class JavaReflectionClass extends AbstractMetaClass { - private Annotation[] _annotationsCache; - - protected JavaReflectionClass(final Class clazz, final boolean erased) { - this(clazz, null, erased); - } - - private JavaReflectionClass(final Class clazz, final Type type, final boolean erased) { - super(clazz); - _asClassCache = clazz; - if (!erased) { - if (type instanceof ParameterizedType) { - super.parameterizedType = new JavaReflectionParameterizedType((ParameterizedType) type); - } - if (clazz.getGenericSuperclass() instanceof ParameterizedType) { - super.genericSuperClass = new JavaReflectionParameterizedType((ParameterizedType) clazz.getGenericSuperclass()); - } - } - } - - private JavaReflectionClass(final TypeLiteral typeLiteral) { - super(typeLiteral.getRawType()); - if (typeLiteral.getType() instanceof ParameterizedType) { - super.parameterizedType = new JavaReflectionParameterizedType((ParameterizedType) typeLiteral.getType()); - } - } - - public static MetaClass newInstance(final Class type) { - if (type == null) return null; - - if (!MetaClassFactory.isCached(type.getName())) { - final MetaClass clazz = newUncachedInstance(type); - MetaClassFactory.getMetaClassCache().pushCache(clazz); - - return clazz; - } - else { - return MetaClassFactory.get(type); - } - } - - public static MetaClass newUncachedInstance(final Class type) { - return new JavaReflectionClass(type, false); - } - - public static MetaClass newUncachedInstance(final Class clazz, final boolean erased) { - return new JavaReflectionClass(clazz, erased); - } - - public static MetaClass newUncachedInstance(final Class clazz, final Type type) { - return new JavaReflectionClass(clazz, type, false); - } - - public static MetaClass newInstance(final TypeLiteral type) { - return MetaClassFactory.get(type); - } - - public static MetaClass newUncachedInstance(final TypeLiteral type) { - return new JavaReflectionClass(type); - } - - @Override - public MetaClass getErased() { - if (parameterizedType == null) { - return this; - } - return new JavaReflectionClass(getEnclosedMetaObject(), true); - } - - @Override - public String getName() { - return getEnclosedMetaObject().getSimpleName(); - } - - @Override - public String getFullyQualifiedName() { - return getEnclosedMetaObject().getName(); - } - - @Override - public String getCanonicalName() { - return getEnclosedMetaObject().getCanonicalName(); - } - - private String _packageName = null; - @Override - public String getPackageName() { - if (_packageName != null) { - return _packageName; - } - - final Package pack = getEnclosedMetaObject().getPackage(); - if (pack != null) { - _packageName = pack.getName(); - } - return _packageName; - } - - private MetaMethod[] fromMethodArray(final Method[] methods) { - final List methodList = new ArrayList<>(); - - for (final Method m : methods) { - // hack to exclude jacoco instrumented methods. - if (!m.isBridge() && !m.getName().startsWith("$jacoco")) { - methodList.add(new JavaReflectionMethod(this, m)); - } - } - - return methodList.toArray(new MetaMethod[methodList.size()]); - } - - private MetaMethod[] _methodCache = null; - - @Override - public MetaMethod[] getMethods() { - if (_methodCache != null) { - return _methodCache; - } - - final Set meths = new LinkedHashSet<>(); - - Class type = getEnclosedMetaObject(); - if (type == null) { - return null; - } - - final Set processedMethods = new HashSet<>(); - do { - for (final Method method : type.getDeclaredMethods()) { - final JavaReflectionMethod metaMethod = new JavaReflectionMethod(this, method); - final String readableMethodDecl = GenUtil.getMethodString(metaMethod); - if (!metaMethod.isPrivate() && !method.isBridge() && !processedMethods.contains(readableMethodDecl)) { - meths.add(metaMethod); - processedMethods.add(readableMethodDecl); - } - } - - // we don't need to recurse on interfaces in this case because we already get the list of - // all inherited methods from Class.getMethods() -- interface methods are public - for (final Class interfaceType : type.getInterfaces()) { - for (final MetaMethod ifaceMethod : Arrays.asList(JavaReflectionClass.newInstance(interfaceType).getMethods())) { - final String readableMethodDecl = GenUtil.getMethodString(ifaceMethod); - if (!processedMethods.contains(readableMethodDecl)) { - meths.add(ifaceMethod); - processedMethods.add(readableMethodDecl); - } - } - } - } - while ((type = type.getSuperclass()) != null); - - _methodCache = meths.toArray(new MetaMethod[meths.size()]); - return _methodCache; - } - - private transient volatile MetaMethod[] _declaredMethodCache; - - @Override - public MetaMethod[] getDeclaredMethods() { - return _declaredMethodCache != null ? _declaredMethodCache - : (_declaredMethodCache = fromMethodArray(getEnclosedMetaObject().getDeclaredMethods())); - } - - - private static MetaField[] fromFieldArray(final Field[] methods) { - return Arrays.stream(methods).map(f -> new JavaReflectionField(f)).toArray(s -> new MetaField[s]); - } - - private transient volatile MetaField[] _fieldCache; - - @Override - public MetaField[] getFields() { - return _fieldCache != null ? _fieldCache : (_fieldCache = fromFieldArray(getEnclosedMetaObject().getFields())); - } - - private transient volatile MetaField[] _declaredFieldCache; - - @Override - public MetaField[] getDeclaredFields() { - return _declaredFieldCache != null ? _declaredFieldCache - : (_declaredFieldCache = fromFieldArray(getEnclosedMetaObject().getDeclaredFields())); - } - - @Override - public MetaField getField(final String name) { - try { - final MetaField mFld; - if ("length".equals(name) && getEnclosedMetaObject().isArray()) { - mFld = new MetaField.ArrayLengthMetaField(this); - } - else { - mFld = new JavaReflectionField(getEnclosedMetaObject().getField(name)); - } - return mFld; - } - catch (final Exception e) { - return null; - } - } - - @Override - public MetaField getDeclaredField(final String name) { - try { - final MetaField mFld; - - if ("length".equals(name) && getEnclosedMetaObject().isArray()) { - mFld = new MetaField.ArrayLengthMetaField(this); - } - else { - mFld = new JavaReflectionField(getEnclosedMetaObject().getDeclaredField(name)); - } - return mFld; - } - catch (final Exception e) { - return null; - } - } - - - private transient volatile MetaConstructor[] constructorCache; - - @Override - public MetaConstructor[] getConstructors() { - if (constructorCache != null) { - return constructorCache; - } - - return constructorCache = Arrays.stream(getEnclosedMetaObject().getConstructors()) - .map(c -> new JavaReflectionConstructor(c)).toArray(s -> new MetaConstructor[s]); - } - - private transient volatile MetaConstructor[] declConstructorCache; - - @Override - public MetaConstructor[] getDeclaredConstructors() { - if (getEnclosedMetaObject().isEnum()) { - // Enum constructors have strange metadata, so we avoid trouble by saying enums have no constructors - // (getParameterTypes().length != getGenericParameterTypes().length) - return new MetaConstructor[0]; - } - - if (declConstructorCache != null) { - return declConstructorCache; - } - return declConstructorCache = Arrays.stream(getEnclosedMetaObject().getDeclaredConstructors()) - .map(c -> new JavaReflectionConstructor(c)).toArray(s -> new MetaConstructor[s]); - } - - @Override - public MetaConstructor getConstructor(final Class... parameters) { - try { - return new JavaReflectionConstructor(getEnclosedMetaObject().getConstructor(parameters)); - } - catch (final Exception e) { - return null; - } - } - - @Override - public MetaConstructor getDeclaredConstructor(final Class... parameters) { - try { - return new JavaReflectionConstructor(getEnclosedMetaObject().getDeclaredConstructor(parameters)); - } - catch (final Exception e) { - return null; - } - } - - @Override - public MetaClass[] getDeclaredClasses() { - final Class[] declaredClasses = getEnclosedMetaObject().getDeclaredClasses(); - final MetaClass[] declaredClassesMC = new MetaClass[declaredClasses.length]; - int i = 0; - for (final Class c : declaredClasses) { - declaredClassesMC[i++] = MetaClassFactory.get(c); - } - return declaredClassesMC; - } - - private MetaClass[] _interfacesCache; - - @Override - public MetaClass[] getInterfaces() { - if (_interfacesCache != null) { - return _interfacesCache; - } - - final List metaClassList = new ArrayList<>(); - final Type[] genIface = getEnclosedMetaObject().getGenericInterfaces(); - - int i = 0; - for (final Class type : getEnclosedMetaObject().getInterfaces()) { - if (genIface != null) { - metaClassList.add(new JavaReflectionClass(type, genIface[i], false)); - } - else { - metaClassList.add(new JavaReflectionClass(type, false)); - } - i++; - } - - return _interfacesCache = metaClassList.toArray(new MetaClass[metaClassList.size()]); - } - - private MetaClass _superClass; - - @Override - public MetaClass getSuperClass() { - if (_superClass != null) - return _superClass; - - if (getGenericSuperClass() != null) { - _superClass = parameterizedAs(getEnclosedMetaObject().getSuperclass(), typeParametersOf(getGenericSuperClass() - .getTypeParameters())); - } - else { - _superClass = newInstance(getEnclosedMetaObject().getSuperclass()); - } - return _superClass; - } - - @Override - public MetaClass getComponentType() { - return MetaClassFactory.get(getEnclosedMetaObject().getComponentType()); - } - - @Override - public synchronized Annotation[] getAnnotations() { - if (_annotationsCache == null) { - _annotationsCache = getEnclosedMetaObject().getAnnotations(); - } - return _annotationsCache; - } - - @Override - public MetaTypeVariable[] getTypeParameters() { - return JavaReflectionUtil.fromTypeVariable(getEnclosedMetaObject().getTypeParameters()); - } - - - @Override - public boolean isPrimitive() { - return getEnclosedMetaObject().isPrimitive(); - } - - @Override - public boolean isVoid() { - return getEnclosedMetaObject().equals(Void.TYPE); - } - - @Override - public boolean isInterface() { - return getEnclosedMetaObject().isInterface(); - } - - @Override - public boolean isAbstract() { - return (getEnclosedMetaObject().getModifiers() & Modifier.ABSTRACT) != 0; - } - - @Override - public boolean isArray() { - return getEnclosedMetaObject().isArray(); - } - - @Override - public boolean isEnum() { - return getEnclosedMetaObject().isEnum(); - } - - @Override - public boolean isAnnotation() { - return getEnclosedMetaObject().isAnnotation(); - } - - @Override - public boolean isPublic() { - return (getEnclosedMetaObject().getModifiers() & Modifier.PUBLIC) != 0; - } - - @Override - public boolean isPrivate() { - return (getEnclosedMetaObject().getModifiers() & Modifier.PRIVATE) != 0; - } - - @Override - public boolean isProtected() { - return (getEnclosedMetaObject().getModifiers() & Modifier.PROTECTED) != 0; - } - - @Override - public boolean isFinal() { - return (getEnclosedMetaObject().getModifiers() & Modifier.FINAL) != 0; - } - - @Override - public boolean isStatic() { - return (getEnclosedMetaObject().getModifiers() & Modifier.STATIC) != 0; - } - - @Override - public boolean isSynthetic() { - return getEnclosedMetaObject().isSynthetic(); - } - - @Override - public boolean isAnonymousClass() { - return getEnclosedMetaObject().isAnonymousClass(); - } - - private final Map _arrayTypeCache = new HashMap<>(); - - @Override - public MetaClass asArrayOf(final int dimensions) { - MetaClass arrayType = _arrayTypeCache.get(dimensions); - if (arrayType == null) { - _arrayTypeCache.put(dimensions, arrayType = MetaClassFactory.getArrayOf(getEnclosedMetaObject(), dimensions)); - } - return arrayType; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/java/JavaReflectionConstructor.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/java/JavaReflectionConstructor.java deleted file mode 100644 index 3b5e859176c..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/java/JavaReflectionConstructor.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta.impl.java; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Constructor; -import java.lang.reflect.Modifier; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.List; - -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.meta.MetaConstructor; -import org.jboss.errai.codegen.meta.MetaParameter; -import org.jboss.errai.codegen.meta.MetaType; -import org.jboss.errai.codegen.meta.MetaTypeVariable; -import org.jboss.errai.codegen.util.GenUtil; - -/** - * @author Mike Brock - */ -public class JavaReflectionConstructor extends MetaConstructor { - private final Constructor constructor; - private MetaParameter[] parameters; - private MetaClass declaringClass; - private volatile Annotation[] annotationsCache; - - JavaReflectionConstructor(final Constructor c) { - constructor = c; - } - - @Override - public MetaParameter[] getParameters() { - if (parameters == null) { - - final Class[] parmTypes = constructor.getParameterTypes(); - final Type[] genParmTypes = constructor.getGenericParameterTypes(); - final Annotation[][] parmAnnos = constructor.getParameterAnnotations(); - final List parmList = new ArrayList<>(parmTypes.length); - - for (int i = 0; i < parmTypes.length; i++) { - final MetaClass mcParm = MetaClassFactory.get(parmTypes[i], genParmTypes[i]); - parmList.add(new JavaReflectionParameter(mcParm, parmAnnos[i], this)); - } - - parameters = parmList.toArray(new MetaParameter[parmList.size()]); - } - - return parameters; - } - - @Override - public MetaClass getDeclaringClass() { - if (declaringClass == null) { - declaringClass = MetaClassFactory.get(constructor.getDeclaringClass()); - } - return declaringClass; - } - - @Override - public String getDeclaringClassName() { - return getDeclaringClass().getName(); - } - - private MetaType[] _genericParameterTypes; - - @Override - public MetaType[] getGenericParameterTypes() { - if (_genericParameterTypes != null) return _genericParameterTypes; - return _genericParameterTypes = JavaReflectionUtil.fromTypeArray(constructor.getGenericParameterTypes()); - } - - private MetaTypeVariable[] _typeParameters; - - @Override - public MetaTypeVariable[] getTypeParameters() { - if (_typeParameters != null) return _typeParameters; - return _typeParameters = JavaReflectionUtil.fromTypeVariable(constructor.getTypeParameters()); - } - - @Override - public String getName() { - return ""; - } - - @Override - public MetaClass getReturnType() { - return getDeclaringClass(); - } - - @Override - public MetaType getGenericReturnType() { - return getDeclaringClass(); - } - - @Override - public synchronized Annotation[] getAnnotations() { - if (annotationsCache == null) { - annotationsCache = constructor.getAnnotations(); - } - return annotationsCache; - } - - @Override - public MetaClass[] getCheckedExceptions() { - return new MetaClass[0]; - } - - @Override - public boolean isAbstract() { - return false; - } - - @Override - public boolean isPublic() { - return (constructor.getModifiers() & Modifier.PUBLIC) != 0; - } - - @Override - public boolean isPrivate() { - return (constructor.getModifiers() & Modifier.PRIVATE) != 0; - } - - @Override - public boolean isProtected() { - return (constructor.getModifiers() & Modifier.PROTECTED) != 0; - } - - @Override - public boolean isFinal() { - return false; - } - - @Override - public boolean isStatic() { - return true; - } - - @Override - public boolean isTransient() { - return false; - } - - @Override - public boolean isVolatile() { - return false; - } - - @Override - public boolean isSynchronized() { - return (constructor.getModifiers() & Modifier.SYNCHRONIZED) != 0; - } - - @Override - public boolean isSynthetic() { - return constructor.isSynthetic(); - } - - @Override - public boolean isVarArgs() { - return constructor.isVarArgs(); - } - - @Override - public boolean equals(final Object o) { - return o instanceof MetaConstructor && GenUtil.equals(this, (MetaConstructor) o); - } - - @Override - public Constructor asConstructor() { - return constructor; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/java/JavaReflectionField.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/java/JavaReflectionField.java deleted file mode 100644 index 0a17626d4e6..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/java/JavaReflectionField.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta.impl.java; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; - -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.meta.MetaField; -import org.jboss.errai.codegen.meta.MetaType; - -public class JavaReflectionField extends MetaField { - private final Field field; - - public JavaReflectionField(final Field field) { - this.field = field; - } - - @Override - public String getName() { - return field.getName(); - } - - @Override - public MetaClass getType() { - return MetaClassFactory.get(field.getType(), field.getGenericType()); - } - - private volatile Annotation[] _annotationsCache; - - @Override - public synchronized Annotation[] getAnnotations() { - if (_annotationsCache != null) { - return _annotationsCache; - } - return _annotationsCache = field.getAnnotations(); - } - - @Override - public MetaType getGenericType() { - return JavaReflectionUtil.fromType(field.getGenericType()); - } - - @Override - public MetaClass getDeclaringClass() { - return MetaClassFactory.get(field.getDeclaringClass()); - } - - @Override - public String getDeclaringClassName() { - return field.getDeclaringClass().getName(); - } - - @Override - public boolean isAbstract() { - return (field.getModifiers() & Modifier.ABSTRACT) != 0; - } - - @Override - public boolean isPublic() { - return (field.getModifiers() & Modifier.PUBLIC) != 0; - } - - @Override - public boolean isPrivate() { - return (field.getModifiers() & Modifier.PRIVATE) != 0; - } - - @Override - public boolean isProtected() { - return (field.getModifiers() & Modifier.PROTECTED) != 0; - } - - @Override - public boolean isFinal() { - return (field.getModifiers() & Modifier.FINAL) != 0; - } - - @Override - public boolean isStatic() { - return (field.getModifiers() & Modifier.STATIC) != 0; - } - - @Override - public boolean isTransient() { - return (field.getModifiers() & Modifier.TRANSIENT) != 0; - } - - @Override - public boolean isVolatile() { - return (field.getModifiers() & Modifier.VOLATILE) != 0; - } - - @Override - public boolean isSynthetic() { - return field.isSynthetic(); - } - - @Override - public boolean isSynchronized() { - return (field.getModifiers() & Modifier.SYNCHRONIZED) != 0; - } - - @Override - public Field asField() { - return field; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/java/JavaReflectionGenericArrayType.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/java/JavaReflectionGenericArrayType.java deleted file mode 100644 index 6d81d0b27d4..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/java/JavaReflectionGenericArrayType.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta.impl.java; - -import java.lang.reflect.GenericArrayType; - -import org.jboss.errai.codegen.meta.MetaGenericArrayType; -import org.jboss.errai.codegen.meta.MetaType; - -/** - * @author Mike Brock - */ -public class JavaReflectionGenericArrayType implements MetaGenericArrayType { - private final GenericArrayType type; - - public JavaReflectionGenericArrayType(final GenericArrayType type) { - this.type = type; - } - - @Override - public MetaType getGenericComponentType() { - return JavaReflectionUtil.fromType(type.getGenericComponentType()); - } - - @Override - public String getName() { - return type.toString(); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/java/JavaReflectionMethod.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/java/JavaReflectionMethod.java deleted file mode 100644 index d08072c22be..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/java/JavaReflectionMethod.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta.impl.java; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.List; - -import com.google.common.reflect.TypeToken; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.meta.MetaMethod; -import org.jboss.errai.codegen.meta.MetaParameter; -import org.jboss.errai.codegen.meta.MetaType; -import org.jboss.errai.codegen.meta.MetaTypeVariable; -import org.jboss.errai.common.client.api.Assert; - -public class JavaReflectionMethod extends MetaMethod { - private final Method method; - private final MetaClass declaringClass; - private MetaParameter[] parameters; - private MetaClass returnType; - - public JavaReflectionMethod(final Method method) { - this.declaringClass = MetaClassFactory.get(Assert.notNull(method.getDeclaringClass())); - this.method = Assert.notNull(method); - } - - public JavaReflectionMethod(final MetaClass referenceClass, final Method method) { - this.declaringClass = Assert.notNull(referenceClass); - this.method = Assert.notNull(method); - } - - @Override - public String getName() { - return method.getName(); - } - - @Override - public MetaParameter[] getParameters() { - if (parameters == null) { - final List parmList = new ArrayList(); - - final Class[] parmTypes = method.getParameterTypes(); - final Type[] genParmTypes = method.getGenericParameterTypes(); - final Annotation[][] parameterAnnotations = method.getParameterAnnotations(); - - for (int i = 0; i < parmTypes.length; i++) { - final TypeToken token = TypeToken.of(declaringClass.asClass()); - final Class parmType = token.resolveType(genParmTypes[i]).getRawType(); - - final MetaClass mcParm = MetaClassFactory.get(parmType, genParmTypes[i]); - parmList.add(new JavaReflectionParameter(mcParm, parameterAnnotations[i], this)); - } - parameters = parmList.toArray(new MetaParameter[parmList.size()]); - } - return parameters; - } - - @Override - public MetaClass getReturnType() { - if (returnType == null) { - returnType = MetaClassFactory.get(method.getReturnType()); - } - return returnType; - } - - @Override - public MetaType getGenericReturnType() { - return JavaReflectionUtil.fromType(method.getGenericReturnType()); - } - - @Override - public MetaType[] getGenericParameterTypes() { - return JavaReflectionUtil.fromTypeArray(method.getGenericParameterTypes()); - } - - @Override - public MetaTypeVariable[] getTypeParameters() { - return JavaReflectionUtil.fromTypeVariable(method.getTypeParameters()); - } - - private volatile Annotation[] _annotationsCache; - - @Override - public synchronized Annotation[] getAnnotations() { - if (_annotationsCache != null) - return _annotationsCache; - return _annotationsCache = method.getAnnotations(); - } - - @Override - public MetaClass[] getCheckedExceptions() { - return MetaClassFactory.fromClassArray(method.getExceptionTypes()); - } - - @Override - public MetaClass getDeclaringClass() { - return declaringClass; - } - - @Override - public String getDeclaringClassName() { - return declaringClass.getName(); - } - - @Override - public boolean isAbstract() { - return (method.getModifiers() & Modifier.ABSTRACT) != 0; - } - - @Override - public boolean isPublic() { - return (method.getModifiers() & Modifier.PUBLIC) != 0; - } - - @Override - public boolean isPrivate() { - return (method.getModifiers() & Modifier.PRIVATE) != 0; - } - - @Override - public boolean isProtected() { - return (method.getModifiers() & Modifier.PROTECTED) != 0; - } - - @Override - public boolean isFinal() { - return (method.getModifiers() & Modifier.FINAL) != 0; - } - - @Override - public boolean isStatic() { - return (method.getModifiers() & Modifier.STATIC) != 0; - } - - @Override - public boolean isTransient() { - return (method.getModifiers() & Modifier.TRANSIENT) != 0; - } - - @Override - public boolean isVolatile() { - return false; - } - - @Override - public boolean isSynthetic() { - return method.isSynthetic(); - } - - @Override - public boolean isSynchronized() { - return (method.getModifiers() & Modifier.SYNCHRONIZED) != 0; - } - - @Override - public boolean isVarArgs() { - return method.isVarArgs(); - } - - @Override - public Method asMethod() { - return method; - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/java/JavaReflectionParameter.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/java/JavaReflectionParameter.java deleted file mode 100644 index c9ad4af186e..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/java/JavaReflectionParameter.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta.impl.java; - -import java.lang.annotation.Annotation; -import java.util.concurrent.atomic.AtomicInteger; - -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassMember; -import org.jboss.errai.codegen.meta.MetaParameter; - -/** - * @author Mike Brock - */ -public class JavaReflectionParameter extends MetaParameter { - private final static AtomicInteger paramNameCounter = new AtomicInteger(); - - private final String name; - private final MetaClass type; - private final Annotation[] annotations; - private final MetaClassMember declaredBy; - - public JavaReflectionParameter(final MetaClass type, - final Annotation[] annotations, - final MetaClassMember declaredBy) { - - // Java Reflection doesn't provide parameter names, so we have to make one up to satisfy the Parameter interface. - this.name = "jp" + paramNameCounter.getAndIncrement(); - - this.type = type; - this.annotations = annotations; - this.declaredBy = declaredBy; - } - - @Override - public String getName() { - return name; - } - - @Override - public MetaClass getType() { - return type; - } - - @Override - public Annotation[] getAnnotations() { - return annotations == null ? new Annotation[0] : annotations; - } - - @Override - public MetaClassMember getDeclaringMember() { - return declaredBy; - } - - @Override - public String toString() { - return type.getFullyQualifiedName(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/java/JavaReflectionParameterizedType.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/java/JavaReflectionParameterizedType.java deleted file mode 100644 index 31c85811b16..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/java/JavaReflectionParameterizedType.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta.impl.java; - -import java.lang.reflect.ParameterizedType; - -import org.jboss.errai.codegen.meta.MetaType; -import org.jboss.errai.codegen.meta.impl.AbstractMetaParameterizedType; - -/** - * @author Mike Brock - */ -public class JavaReflectionParameterizedType extends AbstractMetaParameterizedType { - ParameterizedType parameterizedType; - - public JavaReflectionParameterizedType(final ParameterizedType parameterizedType) { - this.parameterizedType = parameterizedType; - } - - @Override - public MetaType[] getTypeParameters() { - return JavaReflectionUtil.fromTypeArray(parameterizedType.getActualTypeArguments()); - } - - @Override - public MetaType getOwnerType() { - return JavaReflectionUtil.fromType(parameterizedType.getOwnerType()); - } - - @Override - public MetaType getRawType() { - return JavaReflectionUtil.fromType(parameterizedType.getRawType()); - } - - @Override - public String getName() { - return parameterizedType.toString(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/java/JavaReflectionTypeVariable.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/java/JavaReflectionTypeVariable.java deleted file mode 100644 index 6f4332d6fa6..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/java/JavaReflectionTypeVariable.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta.impl.java; - -import java.lang.reflect.TypeVariable; - -import org.jboss.errai.codegen.meta.MetaType; -import org.jboss.errai.codegen.meta.MetaTypeVariable; - -/** - * Java Reflection based implementation of {@link MetaTypeVariable}. - * - * @author Mike Brock - * @author Jonathan Fuerth - */ -public class JavaReflectionTypeVariable implements MetaTypeVariable { - private final TypeVariable variable; - - public JavaReflectionTypeVariable(final TypeVariable variable) { - this.variable = variable; - } - - @Override - public MetaType[] getBounds() { - return JavaReflectionUtil.fromTypeArray(variable.getBounds()); - } - - @Override - public String getName() { - return variable.getName(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/java/JavaReflectionUtil.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/java/JavaReflectionUtil.java deleted file mode 100644 index 36805a2db55..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/java/JavaReflectionUtil.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta.impl.java; - -import java.lang.reflect.GenericArrayType; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.lang.reflect.TypeVariable; -import java.lang.reflect.WildcardType; -import java.util.Arrays; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.meta.MetaType; -import org.jboss.errai.codegen.meta.MetaTypeVariable; -import org.jboss.errai.common.rebind.CacheStore; -import org.jboss.errai.common.rebind.CacheUtil; - -/** - * @author Mike Brock - * @author Jonathan Fuerth - */ -public class JavaReflectionUtil { - public static class CacheHolder implements CacheStore { - final Map FROM_TYPE_CLASS = new ConcurrentHashMap(); - - @Override - public void clear() { - FROM_TYPE_CLASS.clear(); - } - } - - public static MetaTypeVariable[] fromTypeVariable(final TypeVariable[] typeVariables) { - return Arrays.stream(typeVariables) - .map(t -> new JavaReflectionTypeVariable(t)).toArray(s -> new MetaTypeVariable[s]); - } - - public static MetaType[] fromTypeArray(final Type[] types) { - return Arrays.stream(types).map(t -> fromType(t)).toArray(s -> new MetaType[s]); - } - - /** - * Returns an instance of the appropriate MetaType that wraps the given Java - * Reflection Type. - * - * @param t - * the Type to wrap in a MetaType - * @return A (possibly cached) MetaType instance that represents the same - * thing as the given Type. Never null. - */ - public static MetaType fromType(final Type t) { - MetaType type = CacheUtil.getCache(CacheHolder.class).FROM_TYPE_CLASS.get(t); - if (type == null) { - if (t instanceof Class) { - type = (MetaClassFactory.get((Class) t)); - } - else if (t instanceof TypeVariable) { - type = new JavaReflectionTypeVariable((TypeVariable) t); - } - else if (t instanceof ParameterizedType) { - type = new JavaReflectionParameterizedType((ParameterizedType) t); - } - else if (t instanceof GenericArrayType) { - type = new JavaReflectionGenericArrayType((GenericArrayType) t); - } - else if (t instanceof WildcardType) { - type = new JavaReflectionWildcardType((WildcardType) t); - } - else { - throw new RuntimeException("Don't know how to make a MetaType from Type " + t + - " (which is a " + (t == null ? null : t.getClass()) + ")"); - } - CacheUtil.getCache(CacheHolder.class).FROM_TYPE_CLASS.put(t, type); - } - - return type; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/java/JavaReflectionWildcardType.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/java/JavaReflectionWildcardType.java deleted file mode 100644 index 34b84d777e8..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/meta/impl/java/JavaReflectionWildcardType.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.meta.impl.java; - -import java.lang.reflect.WildcardType; - -import org.jboss.errai.codegen.meta.MetaType; -import org.jboss.errai.codegen.meta.impl.AbstractMetaWildcardType; - -/** - * @author Mike Brock - */ -public class JavaReflectionWildcardType extends AbstractMetaWildcardType { - private final WildcardType wildcardType; - - public JavaReflectionWildcardType(final WildcardType wildcardType) { - this.wildcardType = wildcardType; - } - - @Override - public MetaType[] getLowerBounds() { - return JavaReflectionUtil.fromTypeArray(wildcardType.getLowerBounds()); - } - - @Override - public MetaType[] getUpperBounds() { - return JavaReflectionUtil.fromTypeArray(wildcardType.getUpperBounds()); - } - - @Override - public String getName() { - return wildcardType.toString(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/AnnotationSerializer.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/AnnotationSerializer.java deleted file mode 100644 index 2c21cfbdf1c..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/AnnotationSerializer.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.jboss.errai.codegen.util; - -import java.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.jboss.errai.common.client.util.SharedAnnotationSerializer; - -public class AnnotationSerializer { - - private AnnotationSerializer() {}; - - public static String[] serialize(final Iterator qualifier) { - final List qualifiers = new ArrayList(); - qualifier.forEachRemaining(a -> qualifiers.add(SharedAnnotationSerializer.serialize(a, CDIAnnotationUtils.createDynamicSerializer(a.annotationType())))); - - return qualifiers.toArray(new String[qualifiers.size()]); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/Arith.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/Arith.java deleted file mode 100644 index b94877dd3d1..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/Arith.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.util; - -import org.jboss.errai.codegen.ArithmeticExpression; -import org.jboss.errai.codegen.ArithmeticOperator; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.builder.impl.ArithmeticExpressionBuilder; - -/** - * @author Christian Sadilek - */ -public class Arith { - - public static ArithmeticExpression expr(final Object lhs, final ArithmeticOperator operator, final Object rhs) { - return ArithmeticExpressionBuilder.create(lhs, operator, rhs); - } - - public static ArithmeticExpression expr(final ArithmeticOperator operator, final Object rhs) { - return ArithmeticExpressionBuilder.create(operator, rhs); - } - - public static ArithmeticExpression expr(final Statement lhs) { - return ArithmeticExpressionBuilder.create(lhs); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/Bitwise.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/Bitwise.java deleted file mode 100644 index 3b0e2471a2e..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/Bitwise.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.util; - -import org.jboss.errai.codegen.BitwiseOperator; -import org.jboss.errai.codegen.Expression; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.builder.impl.BitwiseExpressionBuilder; -import org.jboss.errai.common.client.api.Assert; - -/** - * @author Mike Brock - */ -public class Bitwise { - public static Expression expr(final Object lhs, final BitwiseOperator operator, final Object rhs) { - return BitwiseExpressionBuilder.create(lhs, operator, rhs); - } - - public static Expression expr(final BitwiseOperator operator, final Object rhs) { - return BitwiseExpressionBuilder.create(operator, rhs); - } - - public static Expression expr(final Statement lhs) { - return BitwiseExpressionBuilder.create(lhs); - } - - public static Expression or(final Object lhs, final Object... rhs) { - return append(lhs, BitwiseOperator.Or, rhs); - } - - public static Expression and(final Object lhs, final Object... rhs) { - return append(lhs, BitwiseOperator.And, rhs); - } - - public static Expression xor(final Object lhs, final Object... rhs) { - return append(lhs, BitwiseOperator.Xor, rhs); - } - - public static Expression shiftRight(final Object lhs, final Object... rhs) { - return append(lhs, BitwiseOperator.ShiftRight, rhs); - } - - public static Expression unsignedShiftRight(final Object lhs, final Object... rhs) { - return append(lhs, BitwiseOperator.UnsignedShiftRight, rhs); - } - - public static Expression shiftLeft(final Object lhs, final Object... rhs) { - return append(lhs, BitwiseOperator.ShiftLeft, rhs); - } - - private static Expression append(final Object lhs, - final BitwiseOperator operator, - final Object... rhs) { - Assert.notNull("must specify a right hand side value", rhs); - - if (rhs.length == 0) { - throw new AssertionError("must specifiy at least one right hand side element"); - } - - Expression expr = BitwiseExpressionBuilder.create(lhs, operator, rhs[0]); - - for (int i = 1; i < rhs.length; i++) { - expr = BitwiseExpressionBuilder.createUnqualifying(expr, operator, rhs[i]); - } - - return expr; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/Bool.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/Bool.java deleted file mode 100644 index 1945106956f..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/Bool.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.util; - -import org.jboss.errai.codegen.BooleanExpression; -import org.jboss.errai.codegen.BooleanOperator; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.builder.impl.BooleanExpressionBuilder; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public class Bool { - - public static BooleanExpression expr(final Object lhs, final BooleanOperator operator, final Object rhs) { - return BooleanExpressionBuilder.create(lhs, operator, rhs); - } - - public static BooleanExpression expr(final BooleanOperator operator, final Object rhs) { - return BooleanExpressionBuilder.create(operator, rhs); - } - - public static BooleanExpression expr(final Statement lhs) { - return BooleanExpressionBuilder.create(lhs); - } - - public static BooleanExpression notExpr(final Statement lhs) { - return BooleanExpressionBuilder.create(new Statement() { - @Override - public String generate(final Context context) { - return "!" + lhs.generate(context); - } - - @Override - public MetaClass getType() { - return MetaClassFactory.get(Boolean.class); - } - }); - } - - public static BooleanExpression equals(final Object lhs, final Object rhs) { - return BooleanExpressionBuilder.create(lhs, BooleanOperator.Equals, rhs); - } - - public static BooleanExpression notEquals(final Object lhs, final Object rhs) { - return BooleanExpressionBuilder.create(lhs, BooleanOperator.NotEquals, rhs); - } - - public static BooleanExpression or(final Object lhs, final Object rhs) { - return BooleanExpressionBuilder.create(lhs, BooleanOperator.Or, rhs); - } - - public static BooleanExpression and(final Object lhs, final Object rhs) { - return BooleanExpressionBuilder.create(lhs, BooleanOperator.And, rhs); - } - - public static BooleanExpression instanceOf(final Object lhs, final Class type) { - return instanceOf(lhs, MetaClassFactory.get(type)); - } - - public static BooleanExpression instanceOf(final Object lhs, final MetaClass type) { - return BooleanExpressionBuilder.create(lhs, BooleanOperator.InstanceOf, MetaClassFactory.getAsStatement(type)); - } - - public static BooleanExpression greaterThanOrEqual(final Object lhs, final Object rhs) { - return BooleanExpressionBuilder.create(lhs, BooleanOperator.GreaterThanOrEqual, rhs); - } - - public static BooleanExpression greaterThan(final Object lhs, final Object rhs) { - return BooleanExpressionBuilder.create(lhs, BooleanOperator.GreaterThan, rhs); - } - - public static BooleanExpression lessThanOrEqual(final Object lhs, final Object rhs) { - return BooleanExpressionBuilder.create(lhs, BooleanOperator.LessThanOrEqual, rhs); - } - - public static BooleanExpression lessThan(final Object lhs, final Object rhs) { - return BooleanExpressionBuilder.create(lhs, BooleanOperator.LessThan, rhs); - } - - public static BooleanExpression isNotNull(final Object test) { - return Bool.notEquals(test, null); - } - - public static BooleanExpression isNull(final Object test) { - return Bool.equals(test, null); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/CDIAnnotationUtils.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/CDIAnnotationUtils.java deleted file mode 100644 index 0777b6556bd..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/CDIAnnotationUtils.java +++ /dev/null @@ -1,507 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.util; - -import java.lang.annotation.Annotation; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.Arrays; -import java.util.Collection; -import java.util.Set; -import java.util.function.Function; -import java.util.function.Predicate; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import javax.enterprise.util.Nonbinding; -import javax.inject.Named; -import javax.inject.Qualifier; - -import org.apache.commons.lang3.AnnotationUtils; -import org.apache.commons.lang3.ClassUtils; -import org.apache.commons.lang3.Validate; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.meta.MetaMethod; -import org.jboss.errai.common.client.util.AnnotationPropertyAccessor; -import org.jboss.errai.common.client.util.AnnotationPropertyAccessorBuilder; -import org.jboss.errai.common.metadata.MetaDataScanner; -import org.jboss.errai.common.metadata.ScannerSingleton; - -import static java.lang.reflect.Modifier.isPublic; - -/** - *

- * Helper methods for working with {@link Annotation} instances. - *

- * - *

- * This class contains various utility methods that make working with - * annotations simpler. - *

- * - *

- * This modified version of {@link AnnotationUtils} ignores {@link Nonbinding} - * values when calculating hashcodes and equality, for comparing CDI qualifiers. - *

- * - *

- * {@link Annotation} instances are always proxy objects; unfortunately dynamic - * proxies cannot be depended upon to know how to implement certain methods in - * the same manner as would be done by "natural" {@link Annotation}s. The - * methods presented in this class can be used to avoid that possibility. It is - * of course also possible for dynamic proxies to actually delegate their e.g. - * {@link Annotation#equals(Object)}/{@link Annotation#hashCode()}/ - * {@link Annotation#toString()} implementations to {@link CDIAnnotationUtils}. - *

- * - *

- * #ThreadSafe# - *

- * - */ -public class CDIAnnotationUtils { - - /** - * A style that prints annotations as recommended. - */ - private static final ToStringStyle TO_STRING_STYLE = new ToStringStyle() { - /** Serialization version */ - private static final long serialVersionUID = 1L; - - { - setDefaultFullDetail(true); - setArrayContentDetail(true); - setUseClassName(true); - setUseShortClassName(true); - setUseIdentityHashCode(false); - setContentStart("("); - setContentEnd(")"); - setFieldSeparator(", "); - setArrayStart("["); - setArrayEnd("]"); - } - - /** - * {@inheritDoc} - */ - @Override - protected String getShortClassName(java.lang.Class cls) { - Class annotationType = null; - for (final Class iface : ClassUtils.getAllInterfaces(cls)) { - if (Annotation.class.isAssignableFrom(iface)) { - @SuppressWarnings("unchecked") - final - //because we just checked the assignability - Class found = (Class) iface; - annotationType = found; - break; - } - } - return new StringBuilder(annotationType == null ? "" : annotationType.getName()) - .insert(0, '@').toString(); - } - - /** - * {@inheritDoc} - */ - @Override - protected void appendDetail(StringBuffer buffer, String fieldName, Object value) { - if (value instanceof Annotation) { - value = CDIAnnotationUtils.toString((Annotation) value); - } - super.appendDetail(buffer, fieldName, value); - } - - }; - - /** - *

{@code AnnotationUtils} instances should NOT be constructed in - * standard programming. Instead, the class should be used statically.

- * - *

This constructor is public to permit tools that require a JavaBean - * instance to operate.

- */ - public CDIAnnotationUtils() { - } - - //----------------------------------------------------------------------- - /** - *

Checks if two annotations are equal using the criteria for equality - * presented in the {@link Annotation#equals(Object)} API docs.

- * - * @param a1 the first Annotation to compare, {@code null} returns - * {@code false} unless both are {@code null} - * @param a2 the second Annotation to compare, {@code null} returns - * {@code false} unless both are {@code null} - * @return {@code true} if the two annotations are {@code equal} or both - * {@code null} - */ - public static boolean equals(Annotation a1, Annotation a2) { - if (a1 == a2) { - return true; - } - if (a1 == null || a2 == null) { - return false; - } - final Class type = a1.annotationType(); - final Class type2 = a2.annotationType(); - Validate.notNull(type, "Annotation %s with null annotationType()", a1); - Validate.notNull(type2, "Annotation %s with null annotationType()", a2); - if (!type.equals(type2)) { - return false; - } - try { - for (final Method m : type.getDeclaredMethods()) { - if (m.getParameterTypes().length == 0 - && isValidAnnotationMemberType(m.getReturnType()) - && !m.isAnnotationPresent(Nonbinding.class)) { - final Object v1 = m.invoke(a1); - final Object v2 = m.invoke(a2); - if (!memberEquals(m.getReturnType(), v1, v2)) { - return false; - } - } - } - } catch (final IllegalAccessException ex) { - return false; - } catch (final InvocationTargetException ex) { - return false; - } - return true; - } - - /** - *

Generate a hash code for the given annotation using the algorithm - * presented in the {@link Annotation#hashCode()} API docs.

- * - * @param a the Annotation for a hash code calculation is desired, not - * {@code null} - * @return the calculated hash code - * @throws RuntimeException if an {@code Exception} is encountered during - * annotation member access - * @throws IllegalStateException if an annotation method invocation returns - * {@code null} - */ - public static int hashCode(Annotation a) { - int result = 0; - final Class type = a.annotationType(); - for (final Method m : type.getDeclaredMethods()) { - if (!m.isAnnotationPresent(Nonbinding.class)) { - try { - final Object value = m.invoke(a); - if (value == null) { - throw new IllegalStateException( - String.format("Annotation method %s returned null", m)); - } - result += hashMember(m.getName(), value); - } catch (final RuntimeException ex) { - throw ex; - } catch (final Exception ex) { - throw new RuntimeException(ex); - } - } - } - return result; - } - - /** - *

Generate a string representation of an Annotation, as suggested by - * {@link Annotation#toString()}.

- * - * @param a the annotation of which a string representation is desired - * @return the standard string representation of an annotation, not - * {@code null} - */ - public static String toString(final Annotation a) { - final ToStringBuilder builder = new ToStringBuilder(a, TO_STRING_STYLE); - for (final Method m : a.annotationType().getDeclaredMethods()) { - if (m.getParameterTypes().length > 0) { - continue; //wtf? - } - try { - builder.append(m.getName(), m.invoke(a)); - } catch (final RuntimeException ex) { - throw ex; - } catch (final Exception ex) { - throw new RuntimeException(ex); - } - } - return builder.build(); - } - - /** - *

Checks if the specified type is permitted as an annotation member.

- * - *

The Java language specification only permits certain types to be used - * in annotations. These include {@link String}, {@link Class}, primitive - * types, {@link Annotation}, {@link Enum}, and single-dimensional arrays of - * these types.

- * - * @param type the type to check, {@code null} - * @return {@code true} if the type is a valid type to use in an annotation - */ - public static boolean isValidAnnotationMemberType(Class type) { - if (type == null) { - return false; - } - if (type.isArray()) { - type = type.getComponentType(); - } - return type.isPrimitive() || type.isEnum() || type.isAnnotation() - || String.class.equals(type) || Class.class.equals(type); - } - - //besides modularity, this has the advantage of autoboxing primitives: - /** - * Helper method for generating a hash code for a member of an annotation. - * - * @param name the name of the member - * @param value the value of the member - * @return a hash code for this member - */ - private static int hashMember(String name, Object value) { - final int part1 = name.hashCode() * 127; - if (value.getClass().isArray()) { - return part1 ^ arrayMemberHash(value.getClass().getComponentType(), value); - } - if (value instanceof Annotation) { - return part1 ^ hashCode((Annotation) value); - } - return part1 ^ value.hashCode(); - } - - /** - * Helper method for checking whether two objects of the given type are - * equal. This method is used to compare the parameters of two annotation - * instances. - * - * @param type the type of the objects to be compared - * @param o1 the first object - * @param o2 the second object - * @return a flag whether these objects are equal - */ - private static boolean memberEquals(Class type, Object o1, Object o2) { - if (o1 == o2) { - return true; - } - if (o1 == null || o2 == null) { - return false; - } - if (type.isArray()) { - return arrayMemberEquals(type.getComponentType(), o1, o2); - } - if (type.isAnnotation()) { - return equals((Annotation) o1, (Annotation) o2); - } - return o1.equals(o2); - } - - /** - * Helper method for comparing two objects of an array type. - * - * @param componentType the component type of the array - * @param o1 the first object - * @param o2 the second object - * @return a flag whether these objects are equal - */ - private static boolean arrayMemberEquals(Class componentType, Object o1, Object o2) { - if (componentType.isAnnotation()) { - return annotationArrayMemberEquals((Annotation[]) o1, (Annotation[]) o2); - } - if (componentType.equals(Byte.TYPE)) { - return Arrays.equals((byte[]) o1, (byte[]) o2); - } - if (componentType.equals(Short.TYPE)) { - return Arrays.equals((short[]) o1, (short[]) o2); - } - if (componentType.equals(Integer.TYPE)) { - return Arrays.equals((int[]) o1, (int[]) o2); - } - if (componentType.equals(Character.TYPE)) { - return Arrays.equals((char[]) o1, (char[]) o2); - } - if (componentType.equals(Long.TYPE)) { - return Arrays.equals((long[]) o1, (long[]) o2); - } - if (componentType.equals(Float.TYPE)) { - return Arrays.equals((float[]) o1, (float[]) o2); - } - if (componentType.equals(Double.TYPE)) { - return Arrays.equals((double[]) o1, (double[]) o2); - } - if (componentType.equals(Boolean.TYPE)) { - return Arrays.equals((boolean[]) o1, (boolean[]) o2); - } - return Arrays.equals((Object[]) o1, (Object[]) o2); - } - - /** - * Helper method for comparing two arrays of annotations. - * - * @param a1 the first array - * @param a2 the second array - * @return a flag whether these arrays are equal - */ - private static boolean annotationArrayMemberEquals(Annotation[] a1, Annotation[] a2) { - if (a1.length != a2.length) { - return false; - } - for (int i = 0; i < a1.length; i++) { - if (!equals(a1[i], a2[i])) { - return false; - } - } - return true; - } - - /** - * Helper method for generating a hash code for an array. - * - * @param componentType the component type of the array - * @param o the array - * @return a hash code for the specified array - */ - private static int arrayMemberHash(Class componentType, Object o) { - if (componentType.equals(Byte.TYPE)) { - return Arrays.hashCode((byte[]) o); - } - if (componentType.equals(Short.TYPE)) { - return Arrays.hashCode((short[]) o); - } - if (componentType.equals(Integer.TYPE)) { - return Arrays.hashCode((int[]) o); - } - if (componentType.equals(Character.TYPE)) { - return Arrays.hashCode((char[]) o); - } - if (componentType.equals(Long.TYPE)) { - return Arrays.hashCode((long[]) o); - } - if (componentType.equals(Float.TYPE)) { - return Arrays.hashCode((float[]) o); - } - if (componentType.equals(Double.TYPE)) { - return Arrays.hashCode((double[]) o); - } - if (componentType.equals(Boolean.TYPE)) { - return Arrays.hashCode((boolean[]) o); - } - return Arrays.hashCode((Object[]) o); - } - - public static String formatDefaultElName(final String rawName) { - if (rawName.isEmpty() || Character.isLowerCase(rawName.charAt(0)) || (rawName.length() > 1 && Character.isUpperCase(rawName.charAt(1)))) { - return rawName; - } else { - final StringBuilder builder = new StringBuilder(rawName); - builder.setCharAt(0, Character.toLowerCase(builder.charAt(0))); - - return builder.toString(); - } - } - - public static Set> getQualifiersAsClasses() { - final MetaDataScanner scanner = ScannerSingleton.getOrCreateInstance(); - final Set> typesAnnotatedWith = scanner.getTypesAnnotatedWith(Qualifier.class); - typesAnnotatedWith.add(Named.class); - return typesAnnotatedWith; - } - - public static Set getQualifiers() { - final Set> qualifiersAsClasses = getQualifiersAsClasses(); - final Set qualifiersAsMetaClasses = qualifiersAsClasses.stream().map(c -> MetaClassFactory.get(c)).collect(Collectors.toSet()); - - if (qualifiersAsClasses.size() > qualifiersAsMetaClasses.size()) { - throw new RuntimeException("Lost some qualifiers when converting from Class to MetaClass"); - } - - return qualifiersAsMetaClasses; - } - - public static Collection getAnnotationAttributes(final MetaClass annoClass) { - return filterAnnotationMethods(Arrays.stream(annoClass.getDeclaredMethods()), - method -> !method.isAnnotationPresent(Nonbinding.class) && method.isPublic() - && !method.getName().equals("equals") && !method.getName().equals("hashCode")); - } - - public static Collection getAnnotationAttributes(final Class annoClass) { - return filterAnnotationMethods(Arrays.stream(annoClass.getDeclaredMethods()), - method -> !method.isAnnotationPresent(Nonbinding.class) && isPublic(method.getModifiers()) - && !method.getName().equals("equals") && !method.getName().equals("hashCode")); - } - - public static Collection getNonBindingAttributes(final MetaClass annoClass) { - return filterAnnotationMethods(Arrays.stream(annoClass.getDeclaredMethods()), - method -> method.isAnnotationPresent(Nonbinding.class) && method.isPublic() - && !method.getName().equals("equals") && !method.getName().equals("hashCode")); - } - - public static Collection getNonBindingAttributes(final Class annoClass) { - return filterAnnotationMethods(Arrays.stream(annoClass.getDeclaredMethods()), - method -> method.isAnnotationPresent(Nonbinding.class) && isPublic(method.getModifiers()) - && !method.getName().equals("equals") && !method.getName().equals("hashCode")); - } - - private static Collection filterAnnotationMethods(final Stream methods, final Predicate methodPredicate) { - return methods.filter(methodPredicate).collect(Collectors.toList()); - } - - public static AnnotationPropertyAccessor createDynamicSerializer(final Class annotationType) { - final AnnotationPropertyAccessorBuilder builder = AnnotationPropertyAccessorBuilder.create(); - - final Collection annoAttrs = CDIAnnotationUtils.getAnnotationAttributes(annotationType); - for (final Method attr : annoAttrs) { - builder.with(attr.getName(), anno -> { - try { - final String retVal; - final Function toString = componentToString( - attr.getReturnType().isArray() ? attr.getReturnType().getComponentType() : attr.getReturnType()); - if (attr.getReturnType().isArray()) { - final StringBuilder sb = new StringBuilder(); - final Object[] array = (Object[]) attr.invoke(anno); - sb.append("["); - for (final Object obj : array) { - sb.append(toString.apply(obj)).append(","); - } - sb.replace(sb.length()-1, sb.length(), "]"); - retVal = sb.toString(); - } - else { - retVal = toString.apply(attr.invoke(anno)); - } - return retVal; - } catch (final Exception e) { - throw new RuntimeException(String.format("Could not access '%s' property while serializing %s.", attr.getName(), anno.annotationType()), e); - } - }); - } - - return builder.build(); - } - - private static Function componentToString(final Class returnType) { - if (Class.class.equals(returnType)) { - return o -> ((Class) o).getName(); - } - else { - return o -> String.valueOf(o); - } - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/ClassChangeUtil.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/ClassChangeUtil.java deleted file mode 100644 index b641a2a64bc..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/ClassChangeUtil.java +++ /dev/null @@ -1,659 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.util; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintWriter; -import java.net.URL; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.Enumeration; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Optional; -import java.util.Set; -import java.util.jar.JarFile; -import java.util.regex.Pattern; - -import javax.tools.JavaCompiler; -import javax.tools.ToolProvider; - -import org.eclipse.jdt.core.compiler.CompilationProgress; -import org.eclipse.jdt.core.compiler.batch.BatchCompiler; -import org.eclipse.jdt.internal.compiler.apt.dispatch.BatchAnnotationProcessorManager; -import org.jboss.errai.common.metadata.ErraiAppPropertiesFiles; -import org.jboss.errai.common.metadata.RebindUtils; -import org.slf4j.Logger; - -import static org.slf4j.LoggerFactory.getLogger; - -/** - * @author Mike Brock - */ -/* - * This block prevents the Maven Shade plugin to remove the specified classes - */ -public class ClassChangeUtil { - private static final String USE_NATIVE_JAVA_COMPILER = "errai.marshalling.use_native_javac"; - private static final String CLASSLOADING_MODE_PROPERTY = "errai.marshalling.classloading.mode"; - - private static final String classLoadingMode; - private static final boolean useNativeJavac = Boolean.getBoolean(USE_NATIVE_JAVA_COMPILER); - private static Logger log = getLogger(ClassChangeUtil.class); - - static { - - /* - * This block prevents the Maven Shade plugin to remove the specified classes - */ - @SuppressWarnings ("unused") Class[] classes = new Class[] { - BatchAnnotationProcessorManager.class - }; - - if (System.getProperty(CLASSLOADING_MODE_PROPERTY) != null) { - classLoadingMode = System.getProperty(CLASSLOADING_MODE_PROPERTY); - } - else { - classLoadingMode = "thread"; - } - } - - - private static interface CompilerAdapter { - int compile(OutputStream out, OutputStream errors, String outputPath, String toCompile, String classpath); - } - - public static class JDKCompiler implements CompilerAdapter { - final JavaCompiler compiler; - - public JDKCompiler(final JavaCompiler compiler) { - this.compiler = compiler; - } - - @Override - public int compile(final OutputStream out, final OutputStream errors, final String outputPath, final String toCompile, final String classpath) { - return compiler.run(null, out, errors, "-classpath", classpath, "-d", outputPath, toCompile); - } - } - - public static class JDTCompiler implements CompilerAdapter { - @Override - public int compile(final OutputStream out, - final OutputStream errors, - final String outputPath, - final String toCompile, - final String classpath) { - - return BatchCompiler.compile(new String[] { "-classpath", classpath, "-d", outputPath, "-source", "1.8", toCompile }, - new PrintWriter(out), new PrintWriter(errors), - new CompilationProgress() { - @Override - public void begin(final int remainingWork) { - } - - @Override - public void done() { - } - - @Override - public boolean isCanceled() { - return false; - } - - @Override - public void setTaskName(final String name) { - } - - @Override - public void worked(final int workIncrement, final int remainingWork) { - } - }) ? 0 : -1; - } - } - - public static Class compileAndLoad(final File sourceFile, - final String fullyQualifiedName) throws IOException { - final String packageName = getPackageFromFQCN(fullyQualifiedName); - final String className = getNameFromFQCN(fullyQualifiedName); - - return compileAndLoad(sourceFile, packageName, className); - } - - public static Class compileAndLoad(final File sourceFile, - final String packageName, - final String className) throws IOException { - - return compileAndLoad(sourceFile.getParentFile().getAbsolutePath(), packageName, className); - - } - - public static Class compileAndLoad(final String sourcePath, - final String packageName, - final String className) throws IOException { - final String tempDirectory = RebindUtils.getTempDirectory(); - - return compileAndLoad(sourcePath, packageName, className, tempDirectory); - } - - - public static Class compileAndLoad(final String sourcePath, - final String packageName, - final String className, - final String outputPath) throws IOException { - - final String outputLocation = compileClass(sourcePath, packageName, className, outputPath); - return loadClassDefinition(outputLocation, packageName, className); - } - - public static String compileClass(final String sourcePath, - final String packageName, - final String className, - final String outputPath) { - try { - - final ByteArrayOutputStream errorOutputStream = new ByteArrayOutputStream(); - final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); - final CompilerAdapter adapter; - - if (compiler == null || !useNativeJavac) { - adapter = new JDTCompiler(); - } - else { - adapter = new JDKCompiler(compiler); - } - - final File classOutputDir = new File(outputPath - + File.separatorChar + RebindUtils.packageNameToDirName(packageName) - + File.separatorChar).getAbsoluteFile(); - - // delete any marshaller classes already there - final Pattern matcher = Pattern.compile("^" + className + "(\\.|$).*class$"); - if (classOutputDir.exists()) { - final File[] files = classOutputDir.listFiles(); - if (files != null) { - for (final File file : files) { - if (matcher.matcher(file.getName()).matches()) { - file.delete(); - } - } - } - } - - final StringBuilder sb = new StringBuilder(4096); - final List moduleUrls = ErraiAppPropertiesFiles.getModulesUrls(); - final List classpathElements = new ArrayList<>(moduleUrls.size()); - classpathElements.add(new File(outputPath)); - - log.debug(">>> Searching for all jars"); - for (final URL url : moduleUrls) { - final File file = getFileIfExists(url.getFile()); - if (file != null) { - classpathElements.add(file); - } - } - log.debug("<<< Done searching for all jars"); - - for (final File file : classpathElements) { - sb.append(file.getAbsolutePath()).append(File.pathSeparator); - } - - sb.append(System.getProperty("java.class.path")); - sb.append(findAllJarsByManifest()); - - final String classPath = sb.toString(); - - /** - * Attempt to run the compiler without any classpath specified. - */ - if (adapter.compile(System.out, errorOutputStream, outputPath, - new File(sourcePath + File.separator + className + ".java").getAbsolutePath(), classPath) != 0) { - - System.err.println("*** FAILED TO COMPILE CLASS ***"); - System.err.println("*** Classpath Used: " + classPath); - - for (final byte b : errorOutputStream.toByteArray()) { - System.err.print((char) b); - } - return null; - } - - return new File(classOutputDir.getAbsolutePath() + File.separatorChar - + className + ".class").getAbsolutePath(); - } - catch (final Exception e) { - throw new RuntimeException(e); - } - } - - public static Class loadClassDefinition(final String path, - final String packageName, - final String className) throws IOException { - if (path == null) return null; - - FileInputStream inputStream = new FileInputStream(path); - byte[] classDefinition = new byte[inputStream.available()]; - - final String classBase = path.substring(0, path.length() - ".class".length()); - - final BootstrapClassloader clsLoader = new BootstrapClassloader(new File(path).getParentFile().getAbsolutePath(), - "system".equals(classLoadingMode) ? - ClassLoader.getSystemClassLoader() : - Thread.currentThread().getContextClassLoader()); - - final String fqcn; - if ("".equals(packageName)) { - fqcn = className; - } - else { - fqcn = packageName + "." + className; - } - - boolean success = false; - try { - final Class loadClass = clsLoader.loadClass(fqcn); - success = true; - return loadClass; - } - catch (final Throwable t) { - // fall through - } - finally { - if (success) { - try { - inputStream.close(); - } - catch (final Throwable ignore) { - } - } - } - - inputStream.read(classDefinition); - - final File[] files = new File(path).getParentFile().listFiles(); - if (files != null) { - for (final File file : files) { - if (file.getName().startsWith(className + "$")) { - String s = file.getName(); - s = s.substring(s.indexOf('$') + 1, s.lastIndexOf('.')); - - final String nestedClassName = fqcn + "$" + s; - - Class cls = null; - try { - cls = clsLoader.loadClass(nestedClassName); - } catch (final ClassNotFoundException ignored) { - } - - if (cls != null) - continue; - - final String innerClassBaseName = classBase + "$" + s; - final File innerClass = new File(innerClassBaseName + ".class"); - if (innerClass.exists()) { - try { - inputStream = new FileInputStream(innerClass); - classDefinition = new byte[inputStream.available()]; - inputStream.read(classDefinition); - - clsLoader.defineClassX(nestedClassName, classDefinition, 0, classDefinition.length); - } finally { - inputStream.close(); - } - } - else { - break; - } - } - } - } - - final Class mainClass = clsLoader - .defineClassX(fqcn, classDefinition, 0, classDefinition.length); - - inputStream.close(); - - for (int i = 1; i < Integer.MAX_VALUE; i++) { - - final String nestedClassName = fqcn + "$" + i; - - Class cls = null; - try { - cls = clsLoader.loadClass(nestedClassName); - } - catch (final ClassNotFoundException ignored) { - } - - if (cls != null) continue; - - - final String innerClassBaseName = classBase + "$" + i; - final File innerClass = new File(innerClassBaseName + ".class"); - if (innerClass.exists()) { - try { - inputStream = new FileInputStream(innerClass); - classDefinition = new byte[inputStream.available()]; - inputStream.read(classDefinition); - - clsLoader.defineClassX(nestedClassName, classDefinition, 0, classDefinition.length); - } - finally { - inputStream.close(); - } - } - else { - break; - } - } - - return mainClass; - } - - private static class BootstrapClassloader extends ClassLoader { - private final String searchPath; - - private BootstrapClassloader(final String searchPath, final ClassLoader classLoader) { - super(classLoader); - this.searchPath = searchPath; - } - - public Class defineClassX(final String className, final byte[] b, final int off, final int len) { - return super.defineClass(className, b, off, len); - } - - @Override - protected Class findClass(final String name) throws ClassNotFoundException { - try { - return super.findClass(name); - } - catch (final ClassNotFoundException e) { - try { - FileInputStream inputStream = null; - final byte[] classDefinition; - - - final File innerClass = new File(searchPath + "/" + name.substring(name.lastIndexOf('.') + 1) + ".class"); - if (innerClass.exists()) { - try { - inputStream = new FileInputStream(innerClass); - classDefinition = new byte[inputStream.available()]; - inputStream.read(classDefinition); - - return defineClassX(name, classDefinition, 0, classDefinition.length); - } - finally { - if (inputStream != null) inputStream.close(); - } - - } - } - catch (final IOException e2) { - throw new RuntimeException("failed to load class: " + name, e2); - } - - - } - throw new ClassNotFoundException(name); - } - } - - @SuppressWarnings("rawtypes") - private static String findAllJarsByManifest() { - final StringBuilder cp = new StringBuilder(); - try { - log.debug(">>> Searching for all jars using " + JarFile.MANIFEST_NAME); - final Enumeration[] enumerations = new Enumeration[] - { - Thread.currentThread().getContextClassLoader().getResources(JarFile.MANIFEST_NAME), - ClassLoader.getSystemClassLoader().getResources(JarFile.MANIFEST_NAME) - }; - - for (final Enumeration resEnum : enumerations) { - while (resEnum.hasMoreElements()) { - try { - String path = ((URL) resEnum.nextElement()).getFile(); - path = path.substring(0, path.length() - JarFile.MANIFEST_NAME.length() - 1); - - final File file = getFileIfExists(path); - if (file != null) { - cp.append(File.pathSeparator).append(file.getAbsolutePath()); - } - } - catch (final Exception e) { - log.warn("Ignoring classpath entry with invalid manifest", e); - } - } - } - } - catch (final IOException e1) { - log.warn("Failed to build classpath using manifest discovery. Expect compilation failures...", e1); - } - finally { - log.debug("<<< Done searching for all jars using " + JarFile.MANIFEST_NAME); - } - - return cp.toString(); - } - - public static File getFileIfExists(String path) { - final String originalPath = path; - - if (path.startsWith("file:")) { - path = path.substring(5); - - final int outerElement = path.indexOf('!'); - if (outerElement != -1) { - path = path.substring(0, outerElement); - } - } - else if (path.startsWith("jar:")) { - path = path.substring(4); - - final int outerElement = path.indexOf('!'); - if (outerElement != -1) { - path = path.substring(0, outerElement); - } - } - - final File file = new File(path); - if (file.exists()) { - if (log.isDebugEnabled()) { - log.debug(" EXISTS: " + originalPath + " -> " + file.getAbsolutePath()); - } - return file; - } - - if (log.isDebugEnabled()) { - log.debug(" !EXISTS: " + originalPath + " -> " + file.getAbsolutePath()); - } - return null; - } - - private static String getPackageFromFQCN(final String fqcn) { - final int index = fqcn.lastIndexOf('.'); - if (index == -1) { - return ""; - } - else { - return fqcn.substring(0, index); - } - } - - private static String getNameFromFQCN(final String fqcn) { - final int index = fqcn.lastIndexOf('.'); - if (index == -1) { - return fqcn; - } - else { - return fqcn.substring(index + 1); - } - } - - private static List urlToFile(Enumeration urls) { - final ArrayList files = new ArrayList(); - while (urls.hasMoreElements()) { - final URL url = urls.nextElement(); - if (url.getProtocol().equals("file")) { - files.add(url.getFile()); - } - } - return files; - } - - /** - * Finds all urls of classes that are not in jars. - */ - private static Set getClassLocations(final String packageName, final String simpleClassName) throws IOException { - final String classResource = packageName.replaceAll("\\.", "/") + "/" + simpleClassName + ".class"; - final Set locations = new LinkedHashSet(); - - // look for the class in every classloader we can think of. For example, current thread - // classloading works in Jetty but not JBoss AS 7. - locations.addAll(urlToFile(Thread.currentThread().getContextClassLoader().getResources(classResource))); - locations.addAll(urlToFile(ClassChangeUtil.class.getClassLoader().getResources(classResource))); - locations.addAll(urlToFile(ClassLoader.getSystemResources(classResource))); - - return locations; - } - - public static Optional getNewest(final Set locations) { - return locations.stream() - .map(url -> getFileIfExists(url)) - .filter(f -> f != null) - .max(Comparator.comparingLong(f -> f.lastModified())); - } - - public static Optional> loadClassIfPresent(final String packageName, final String simpleClassName) { - final String fullyQualifiedClassName = packageName + "." + simpleClassName; - - try { - log.info("Searching for class: {}", fullyQualifiedClassName); - final Set locations = getClassLocations(packageName, simpleClassName); - final Optional newest = getNewest(locations); - - if (locations.size() > 1) { - log.warn("*** MULTIPLE VERSIONS OF " + fullyQualifiedClassName + " FOUND IN CLASSPATH: " + - "Attempted to guess the newest one based on file dates. But you should clean your output directories."); - - locations.stream().forEach(loc -> log.warn(" Ambiguous version -> {}", loc)); - } - - if (newest.isPresent()) { - log.info("Loading class {} found at {}", fullyQualifiedClassName, newest.get().getAbsolutePath().toString()); - return Optional.of(loadClassDefinition(newest.get().getAbsolutePath(), packageName, simpleClassName)); - } - else { - log.info("Could not find URL for {}. Attempting to load with context class loader.", fullyQualifiedClassName); - try { - // maybe we're in an appserver with a VFS, so try to load anyways. - final Class loadedClass = Thread.currentThread().getContextClassLoader().loadClass(fullyQualifiedClassName); - log.info("Successfully loaded {} with context class loader.", fullyQualifiedClassName); - return Optional.of(loadedClass); - } - catch (final ClassNotFoundException e) { - log.warn("Could not load {} class.", fullyQualifiedClassName); - - return Optional.empty(); - } - } - } - catch (final IOException e) { - log.warn("Could not read {} class: " + fullyQualifiedClassName, e); - - return Optional.empty(); - } - } - - public static String generateClassFile(final String packageName, final String simpleClassName, - final String sourceDir, final String source, final String outputPath) { - final File outputDir = new File(sourceDir + File.separator + - RebindUtils.packageNameToDirName(packageName) + File.separator); - - final File classOutputPath = new File(outputPath); - - //noinspection ResultOfMethodCallIgnored - outputDir.mkdirs(); - - final File sourceFile - = new File(outputDir.getAbsolutePath() + File.separator + simpleClassName + ".java"); - - RebindUtils.writeStringToFile(sourceFile, source); - - return compileClass(outputDir.getAbsolutePath(), - packageName, - simpleClassName, - classOutputPath.getAbsolutePath()); - } - - public static Class compileAndLoadFromSource(final String packageName, final String simpleClassName, - final String source) { - log.info("Compiling and loading {}.{} from source...", packageName, simpleClassName); - final File directory = - new File(RebindUtils.getTempDirectory() - + "/errai.gen/classes/" + packageName.replaceAll("\\.", "/")); - final File sourceFile = new File(directory.getAbsolutePath() + File.separator + simpleClassName + ".java"); - log.info("Using temporary directory for source and class files: {}", directory.getAbsolutePath()); - - try { - if (directory.exists()) { - log.info("Directory {} already exists. Deleting directory and contents (enable debug logging to see deleted files).", directory.getAbsolutePath()); - final File[] files = directory.listFiles(); - if (files != null) { - for (final File file : files) { - log.debug("Deleting {}", file.getAbsolutePath()); - file.delete(); - } - } - log.debug("Deleting {}", directory.getAbsolutePath()); - directory.delete(); - } - directory.mkdirs(); - - log.info("Writing source file {}...", sourceFile.getAbsolutePath()); - final FileOutputStream outputStream = new FileOutputStream(sourceFile); - outputStream.write(source.getBytes("UTF-8")); - outputStream.flush(); - outputStream.close(); - - log.info("Compiling {}.{} in source file {}...", packageName, simpleClassName, sourceFile.getAbsolutePath()); - final String compiledClassPath = compileClass(directory.getAbsolutePath(), packageName, simpleClassName, - directory.getAbsolutePath()); - - if (compiledClassPath == null) { - log.warn("Could not compile {}.{} in source file {}...", packageName, simpleClassName, sourceFile.getAbsolutePath()); - return null; - } - else { - log.info("Loading compiled class at {}...", compiledClassPath); - return loadClassDefinition(compiledClassPath, packageName, simpleClassName); - } - } - catch (final IOException e) { - - - throw new RuntimeException("failed to generate class ", e); - } - } -} \ No newline at end of file diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/EmptyStatement.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/EmptyStatement.java deleted file mode 100644 index 26c373d2068..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/EmptyStatement.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.util; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; - -/** - * An empty statement. Use {@link #INSTANCE} to obtain an instance of this type. - * - * @author Jonathan Fuerth - * @author Mike Brock - */ -public class EmptyStatement implements Statement { - - /** - * Sharable empty statement instance. - */ - public static final Statement INSTANCE = new EmptyStatement(); - - /** - * Private constructor to enforce singletonness of this class. - */ - private EmptyStatement() { - } - - /** - * Returns the empty string. - */ - @Override - public String generate(Context context) { - return ""; - } - - /** - * Always returns the MetaClass for java.lang.Object. - */ - @Override - public MetaClass getType() { - return MetaClassFactory.get(Object.class); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/Expr.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/Expr.java deleted file mode 100644 index e429cb9b3fe..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/Expr.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.util; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Mike Brock - */ -public class Expr { - public static Statement qualify(final Statement statement) { - return new Statement() { - @Override - public String generate(Context context) { - return "(" + statement.generate(context) + ")"; - } - - @Override - public MetaClass getType() { - return statement.getType(); - } - }; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/GenUtil.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/GenUtil.java deleted file mode 100644 index b32eb70cf8b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/GenUtil.java +++ /dev/null @@ -1,693 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.util; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.DefModifiers; -import org.jboss.errai.codegen.Modifier; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.Variable; -import org.jboss.errai.codegen.VariableReference; -import org.jboss.errai.codegen.builder.impl.Scope; -import org.jboss.errai.codegen.exception.GenerationException; -import org.jboss.errai.codegen.exception.InvalidTypeException; -import org.jboss.errai.codegen.exception.OutOfScopeException; -import org.jboss.errai.codegen.exception.TypeNotIterableException; -import org.jboss.errai.codegen.exception.UndefinedMethodException; -import org.jboss.errai.codegen.literal.LiteralFactory; -import org.jboss.errai.codegen.literal.LiteralValue; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.meta.MetaClassMember; -import org.jboss.errai.codegen.meta.MetaConstructor; -import org.jboss.errai.codegen.meta.MetaField; -import org.jboss.errai.codegen.meta.MetaMethod; -import org.jboss.errai.codegen.meta.MetaParameter; -import org.jboss.errai.codegen.meta.impl.java.JavaReflectionClass; -import org.mvel2.DataConversion; -import org.mvel2.util.NullType; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public class GenUtil { - private static final String PERMISSIVE_PROPERTY = "errai.codegen.permissive"; - private static boolean PERMISSIVE_MODE; - - static { - PERMISSIVE_MODE = System.getProperty(PERMISSIVE_PROPERTY) != null - && Boolean.getBoolean(PERMISSIVE_PROPERTY); - } - - public static boolean isPermissiveMode() { - return PERMISSIVE_MODE; - } - - public static void setPermissiveMode(final boolean permissiveMode) { - PERMISSIVE_MODE = permissiveMode; - } - - public static Statement[] generateCallParameters(final Context context, final Object... parameters) { - return Arrays.stream(parameters).map(p -> generate(context, p)).toArray(s -> new Statement[s]); - } - - public static Statement[] generateCallParameters(final MetaMethod method, - final Context context, - final Object... parameters) { - if (parameters.length != method.getParameters().length && !method.isVarArgs()) { - throw new UndefinedMethodException("Wrong number of parameters"); - } - - final MetaParameter[] methParms = method.getParameters(); - - final Statement[] statements = new Statement[parameters.length]; - int i = 0; - for (Object parameter : parameters) { - if (parameter instanceof Statement) { - if (((Statement) parameter).getType() == null) { - parameter = generate(context, parameter); - } - } - try { - statements[i] = convert(context, parameter, methParms[i++].getType()); - } - catch (final GenerationException t) { - t.appendFailureInfo("in method call: " - + method.getDeclaringClass().getFullyQualifiedName() - + "." + method.getName() + "(" + Arrays.toString(methParms) + ")"); - throw t; - } - } - return statements; - } - - public static Statement generate(final Context context, final Object o) { - if (o instanceof VariableReference) { - return context.getVariable(((VariableReference) o).getName()); - } - else if (o instanceof Variable) { - final Variable v = (Variable) o; - if (context.isScoped(v)) { - return v.getReference(); - } - else { - if (context.isPermissiveMode()) { - return v.getReference(); - } - else { - throw new OutOfScopeException("variable cannot be referenced from this scope: " + v.getName()); - } - } - } - else if (o instanceof Statement) { - ((Statement) o).generate(context); - return (Statement) o; - } - else { - return LiteralFactory.getLiteral(context, o); - } - } - - public static void assertIsIterable(final Statement statement) { - final Class cls = statement.getType().asClass(); - - if (!cls.isArray() && !Iterable.class.isAssignableFrom(cls)) - throw new TypeNotIterableException(statement.generate(Context.create())); - } - - private static final Set classAliases = new HashSet() { - { - add(JavaReflectionClass.class.getName()); - add(Class.class.getName()); - } - }; - - public static void addClassAlias(final Class cls) { - classAliases.add(cls.getName()); - } - - public static void assertAssignableTypes(final Context context, final MetaClass from, final MetaClass to) { - if (!to.asBoxed().isAssignableFrom(from.asBoxed())) { - if (to.isArray() && from.isArray() - && GenUtil.getArrayDimensions(to) == GenUtil.getArrayDimensions(from) - && to.getOuterComponentType().isAssignableFrom(from.getOuterComponentType())) { - return; - } - - if (!context.isPermissiveMode()) { - if (classAliases.contains(from.getFullyQualifiedName()) && classAliases.contains(to.getFullyQualifiedName())) { - // handle convertibility between MetaClass API and java Class reference. - return; - } - - throw new InvalidTypeException(to.getFullyQualifiedName() + " is not assignable from " - + from.getFullyQualifiedName()); - } - } - } - - public static Statement convert(final Context context, Object input, final MetaClass targetType) { - try { - if (input instanceof Statement) { - if (input instanceof LiteralValue) { - input = ((LiteralValue) input).getValue(); - } - else { - if ("null".equals(((Statement) input).generate(context))) { - return (Statement) input; - } - - assertAssignableTypes(context, ((Statement) input).getType(), targetType); - return (Statement) input; - } - } - - if (input != null && MetaClassFactory.get(input.getClass()) - .getOuterComponentType().getFullyQualifiedName().equals(MetaClass.class.getName())) { - return generate(context, input); - } - - if (Object.class.getName().equals(targetType.getFullyQualifiedName())) { - return generate(context, input); - } - - Class inputClass = input == null ? Object.class : input.getClass(); - - if (MetaClass.class.isAssignableFrom(inputClass)) { - inputClass = Class.class; - } - - final Class targetClass = targetType.asBoxed().asClass(); - if (NullType.class.getName().equals(targetClass.getName())) { - return generate(context, input); - } - - if (!targetClass.isAssignableFrom(inputClass) && DataConversion.canConvert(targetClass, inputClass)) { - return generate(context, DataConversion.convert(input, targetClass)); - } - else { - return generate(context, input); - } - } - catch (final NumberFormatException nfe) { - throw new InvalidTypeException(nfe); - } - } - - public static String classesAsStrings(final MetaClass... stmt) { - final StringBuilder buf = new StringBuilder(128); - for (int i = 0; i < stmt.length; i++) { - buf.append(stmt[i].getFullyQualifiedName()); - if (i + 1 < stmt.length) { - buf.append(", "); - } - } - return buf.toString(); - } - - public static MetaClass[] fromParameters(final MetaParameter... parms) { - return Arrays.stream(parms).map(p -> p.getType()).toArray(s -> new MetaClass[s]); - } - - public static MetaClass[] classToMeta(final Class[] types) { - return Arrays.stream(types).map(t -> MetaClassFactory.get(t)).toArray(s -> new MetaClass[s]); - } - - public static Scope scopeOf(final MetaClass clazz) { - if (clazz.isPublic()) { - return Scope.Public; - } - else if (clazz.isPrivate()) { - return Scope.Private; - } - else if (clazz.isProtected()) { - return Scope.Protected; - } - else { - return Scope.Package; - } - } - - public static Scope scopeOf(final MetaClassMember member) { - if (member.isPublic()) { - return Scope.Public; - } - else if (member.isPrivate()) { - return Scope.Private; - } - else if (member.isProtected()) { - return Scope.Protected; - } - else { - return Scope.Package; - } - } - - public static DefModifiers modifiersOf(final MetaClassMember member) { - final DefModifiers defModifiers = new DefModifiers(); - if (member.isAbstract()) { - defModifiers.addModifiers(Modifier.Abstract); - } - else if (member.isFinal()) { - defModifiers.addModifiers(Modifier.Final); - } - else if (member.isStatic()) { - defModifiers.addModifiers(Modifier.Static); - } - else if (member.isSynchronized()) { - defModifiers.addModifiers(Modifier.Synchronized); - } - else if (member.isVolatile()) { - defModifiers.addModifiers(Modifier.Volatile); - } - else if (member.isTransient()) { - defModifiers.addModifiers(Modifier.Transient); - } - return defModifiers; - } - - public static boolean equals(final MetaField a, final MetaField b) { - return a.getName().equals(b.getName()) && !a.getType().equals(b.getType()) - && !a.getDeclaringClass().equals(b.getDeclaringClass()); - } - - public static boolean equals(final MetaConstructor a, final MetaConstructor b) { - if (a.getParameters().length != b.getParameters().length) { - return false; - } - - for (int i = 0; i < a.getParameters().length; i++) { - if (!equals(a.getParameters()[i], b.getParameters()[i])) { - return false; - } - } - - return a.getDeclaringClass().equals(b.getDeclaringClass()); - } - - public static boolean equals(final MetaMethod a, final MetaMethod b) { - if (!a.getName().equals(b.getName())) return false; - if (a.getParameters().length != b.getParameters().length) return false; - if (!a.getDeclaringClass().equals(b.getDeclaringClass())) return false; - - for (int i = 0; i < a.getParameters().length; i++) { - if (!equals(a.getParameters()[i], b.getParameters()[i])) return false; - } - return true; - } - - public static boolean equals(final MetaParameter a, final MetaParameter b) { - return a.getType().isAssignableFrom(b.getType()) || b.getType().isAssignableFrom(a.getType()); - } - - public static String getMethodString(final MetaMethod method) { - return method.getName() + "(" + Arrays.toString(method.getParameters()) + ")"; - } - - public static MetaClass getPrimitiveWrapper(final MetaClass clazz) { - if (clazz.isPrimitive()) { - if ("int".equals(clazz.getCanonicalName())) { - return MetaClassFactory.get(Integer.class); - } - else if ("boolean".equals(clazz.getCanonicalName())) { - return MetaClassFactory.get(Boolean.class); - } - else if ("long".equals(clazz.getCanonicalName())) { - return MetaClassFactory.get(Long.class); - } - else if ("double".equals(clazz.getCanonicalName())) { - return MetaClassFactory.get(Double.class); - } - else if ("float".equals(clazz.getCanonicalName())) { - return MetaClassFactory.get(Float.class); - } - else if ("short".equals(clazz.getCanonicalName())) { - return MetaClassFactory.get(Short.class); - } - else if ("char".equals(clazz.getCanonicalName())) { - return MetaClassFactory.get(Character.class); - } - else if ("byte".equals(clazz.getCanonicalName())) { - return MetaClassFactory.get(Byte.class); - } - } - return clazz; - } - - public static boolean isPrimitiveWrapper(final MetaClass clazz) { - return Integer.class.getName().equals(clazz.getFullyQualifiedName()) - || Boolean.class.getName().equals(clazz.getFullyQualifiedName()) - || Long.class.getName().equals(clazz.getFullyQualifiedName()) - || Double.class.getName().equals(clazz.getFullyQualifiedName()) - || Float.class.getName().equals(clazz.getFullyQualifiedName()) - || Short.class.getName().equals(clazz.getFullyQualifiedName()) - || Character.class.getName().equals(clazz.getFullyQualifiedName()) - || Byte.class.getName().equals(clazz.getFullyQualifiedName()); - } - - public static MetaClass getUnboxedFromWrapper(final MetaClass clazz) { - if (Integer.class.getName().equals(clazz.getFullyQualifiedName())) { - return MetaClassFactory.get(int.class); - } - else if (Boolean.class.getName().equals(clazz.getFullyQualifiedName())) { - return MetaClassFactory.get(boolean.class); - } - else if (Long.class.getName().equals(clazz.getFullyQualifiedName())) { - return MetaClassFactory.get(long.class); - } - else if (Double.class.getName().equals(clazz.getFullyQualifiedName())) { - return MetaClassFactory.get(double.class); - } - else if (Float.class.getName().equals(clazz.getFullyQualifiedName())) { - return MetaClassFactory.get(float.class); - } - else if (Short.class.getName().equals(clazz.getFullyQualifiedName())) { - return MetaClassFactory.get(short.class); - } - else if (Character.class.getName().equals(clazz.getFullyQualifiedName())) { - return MetaClassFactory.get(char.class); - } - else if (Byte.class.getName().equals(clazz.getFullyQualifiedName())) { - return MetaClassFactory.get(byte.class); - } - return clazz; - } - - public static int getArrayDimensions(final MetaClass type) { - if (!type.isArray()) return 0; - - final String internalName = type.getInternalName(); - for (int i = 0; i < internalName.length(); i++) { - if (internalName.charAt(i) != '[') return i; - } - return 0; - } - - public static MetaMethod findCaseInsensitiveMatch(final MetaClass retType, - final MetaClass clazz, - final String name, - final MetaClass... parms) { - MetaClass c = clazz; - - do { - Outer: - for (final MetaMethod method : c.getDeclaredMethods()) { - if (name.equalsIgnoreCase(method.getName())) { - if (parms.length != method.getParameters().length) continue; - - final MetaParameter[] mps = method.getParameters(); - for (int i = 0; i < parms.length; i++) { - if (!parms[i].getFullyQualifiedName().equals(mps[i].getType().getFullyQualifiedName())) { - continue Outer; - } - } - - if (retType != null - && !retType.getFullyQualifiedName().equals(method.getReturnType().getFullyQualifiedName())) { - continue; - } - - return method; - } - } - } - while ((c = c.getSuperClass()) != null); - - return null; - } - - public static void throwIfUnhandled(final String error, final Throwable t) { - try { - throw t; - } - catch (final RuntimeException e) { - throw e; - } - catch (final Throwable e) { - throw new RuntimeException("generation failure at: " + error, e); - } - } - - public static MetaMethod getBestCandidate(final MetaClass[] arguments, - final String method, - final MetaClass decl, - MetaMethod[] methods, - final boolean classTarget) { - if (methods == null || methods.length == 0) { - return null; - } - - MetaParameter[] parmTypes; - MetaMethod bestCandidate = null; - int bestScore = 0; - int score; - boolean retry = false; - - do { - for (final MetaMethod meth : methods) { - if (classTarget && (meth.isStatic())) continue; - - if (method.equals(meth.getName())) { - final boolean isVarArgs = meth.isVarArgs(); - if ((parmTypes = meth.getParameters()).length != arguments.length && !isVarArgs) { - continue; - } - else if (arguments.length == 0 && parmTypes.length == 0) { - bestCandidate = meth; - break; - } - - score = scoreMethods(arguments, parmTypes, isVarArgs); - - if (score != 0 && score > bestScore) { - bestCandidate = meth; - bestScore = score; - } - } - } - - if (!retry && bestCandidate == null && decl.isInterface()) { - final MetaMethod[] objMethods = Object_MetaClass.getMethods(); - final MetaMethod[] nMethods = new MetaMethod[methods.length + objMethods.length]; - System.arraycopy(methods, 0, nMethods, 0, methods.length); - System.arraycopy(objMethods, 0, nMethods, methods.length, objMethods.length); - methods = nMethods; - - retry = true; - } - else { - break; - } - } - while (true); - - return bestCandidate; - } - - public static int scoreMethods(final MetaClass[] arguments, final MetaParameter[] parmTypes, final boolean isVarArgs) { - int score = 0; - for (int i = 0; i != arguments.length; i++) { - final MetaClass actualParamType; - if (isVarArgs && !arguments[arguments.length - 1].isArray() && i >= parmTypes.length - 1) - actualParamType = parmTypes[parmTypes.length - 1].getType().getComponentType(); - else - actualParamType = parmTypes[i].getType(); - - if (arguments[i] == null) { - if (!actualParamType.isPrimitive()) { - score += 6; - } - else { - score = 0; - break; - } - } - else if (actualParamType.equals(arguments[i])) { - score += 7; - } - else if (actualParamType.isPrimitive() && actualParamType.asBoxed().equals(arguments[i])) { - score += 6; - } - else if (arguments[i].isPrimitive() && arguments[i].asUnboxed().equals(actualParamType)) { - score += 6; - } - else if (actualParamType.isAssignableFrom(arguments[i])) { - score += 5; - } - else if (isNumericallyCoercible(arguments[i], actualParamType)) { - score += 4; - } - else if (actualParamType.asBoxed().isAssignableFrom(arguments[i].asBoxed()) - && !Object_MetaClass.equals(arguments[i])) { - score += 3 + scoreInterface(actualParamType, arguments[i]); - } - else if (canConvert(actualParamType, arguments[i])) { - if (actualParamType.isArray() && arguments[i].isArray()) { - final MetaClass outerComponentTypeActual = actualParamType.getOuterComponentType(); - final MetaClass outerComponentTypeArg = arguments[i].getOuterComponentType(); - - if (canConvert(outerComponentTypeActual, outerComponentTypeArg)) { - score += 1; - } - else { - continue; - } - } - else if (actualParamType.equals(char_MetaClass) && arguments[i].equals(String_MetaClass)) { - score += 1; - } - - score += 1; - } - else if (actualParamType.equals(Object_MetaClass) || arguments[i].equals(NullType_MetaClass)) { - score += 1; - } - else { - score = 0; - break; - } - } - return score; - } - - public static MetaConstructor getBestConstructorCandidate(final MetaClass[] arguments, - final MetaClass decl, - MetaConstructor[] constructors, - final boolean classTarget) { - if (constructors == null || constructors.length == 0) { - return null; - } - - MetaParameter[] parmTypes; - MetaConstructor bestCandidate = null; - int bestScore = 0; - int score; - boolean retry = false; - - do { - for (final MetaConstructor meth : constructors) { - if (classTarget && (meth.isStatic())) continue; - - final boolean isVarArgs = meth.isVarArgs(); - if ((parmTypes = meth.getParameters()).length != arguments.length && !isVarArgs) { - continue; - } - else if (arguments.length == 0 && parmTypes.length == 0) { - bestCandidate = meth; - break; - } - - score = scoreMethods(arguments, parmTypes, isVarArgs); - - if (score != 0 && score > bestScore) { - bestCandidate = meth; - bestScore = score; - } - } - - if (!retry && bestCandidate == null && decl.isInterface()) { - final MetaConstructor[] objMethods = Object_MetaClass.getConstructors(); - final MetaConstructor[] nMethods = new MetaConstructor[constructors.length + objMethods.length]; - System.arraycopy(constructors, 0, nMethods, 0, constructors.length); - System.arraycopy(objMethods, 0, nMethods, constructors.length, objMethods.length); - constructors = nMethods; - - retry = true; - } - else { - break; - } - } - while (true); - - return bestCandidate; - } - - private static final MetaClass Number_MetaClass = MetaClassFactory.get(Number.class); - private static final MetaClass Object_MetaClass = MetaClassFactory.get(Object.class); - private static final MetaClass NullType_MetaClass = MetaClassFactory.get(NullType.class); - private static final MetaClass char_MetaClass = MetaClassFactory.get(char.class); - private static final MetaClass String_MetaClass = MetaClassFactory.get(String.class); - - public static boolean canConvert(final MetaClass to, final MetaClass from) { - try { - final Class fromClazz = from.asClass(); - final Class toClass = to.asClass(); - - return DataConversion.canConvert(toClass, fromClazz); - } - catch (final Throwable t) { - return false; - } - } - - public static boolean isNumericallyCoercible(final MetaClass target, final MetaClass parm) { - MetaClass boxedTarget = target.isPrimitive() ? target.asBoxed() : target; - - if (boxedTarget != null && Number_MetaClass.isAssignableFrom(target)) { - if ((boxedTarget = parm.isPrimitive() ? parm.asBoxed() : parm) != null) { - return Number_MetaClass.isAssignableFrom(boxedTarget); - } - } - return false; - } - - public static int scoreInterface(final MetaClass parm, final MetaClass arg) { - if (parm.isInterface()) { - final MetaClass[] iface = arg.getInterfaces(); - if (iface != null) { - for (final MetaClass c : iface) { - if (c == parm) return 1; - else if (parm.isAssignableFrom(c)) return scoreInterface(parm, arg.getSuperClass()); - } - } - } - return 0; - } - - public static void rewriteBlameStackTrace(final Throwable innerBlame) { - final StackTraceElement[] stackTrace = innerBlame.getStackTrace(); - - final List innerStackTrace = new ArrayList(10); - final List outerStackTrace = new ArrayList(10); - for (final StackTraceElement el : stackTrace) { - if (el.getClassName().startsWith("org.jboss.errai.codegen.")) { - innerStackTrace.add(el); - } - else { - outerStackTrace.add(el); - } - } - - innerBlame.setStackTrace(innerStackTrace.toArray(new StackTraceElement[innerStackTrace.size()])); - - final RuntimeException outerBlame = new RuntimeException("External call to API"); - outerBlame.setStackTrace(outerStackTrace.toArray(new StackTraceElement[outerStackTrace.size()])); - innerBlame.initCause(outerBlame); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/If.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/If.java deleted file mode 100644 index 8fa213ca432..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/If.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.util; - -import org.jboss.errai.codegen.BooleanExpression; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.builder.BlockBuilder; -import org.jboss.errai.codegen.builder.ElseBlockBuilder; -import org.jboss.errai.codegen.builder.impl.StatementBuilder; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; - -/** - * @author Mike Brock - */ -public class If { - public static BlockBuilder cond(final Statement condition) { - return StatementBuilder.create().if_(Bool.expr(condition)); - } - - public static BlockBuilder cond(final BooleanExpression condition) { - return StatementBuilder.create().if_(condition); - } - - public static BlockBuilder isNull(final Object statement) { - return StatementBuilder.create().if_(Bool.isNull(statement)); - } - - public static BlockBuilder isNotNull(final Object statement) { - return StatementBuilder.create().if_(Bool.isNotNull(statement)); - } - - public static BlockBuilder not(final Statement statement) { - return StatementBuilder.create().if_(Bool.notExpr(statement)); - } - - public static BlockBuilder isEqual(final Object lhs, - final Object rhs) { - return StatementBuilder.create().if_(Bool.equals(lhs, rhs)); - } - - public static BlockBuilder notEquals(final Object lhs, - final Object rhs) { - return StatementBuilder.create().if_(Bool.notEquals(lhs, rhs)); - } - - public static BlockBuilder idEquals(final Object lhs, - final Object rhs) { - return StatementBuilder.create().if_(Bool.equals(lhs, rhs)); - } - - public static BlockBuilder idNotEquals(final Object lhs, - final Object rhs) { - return StatementBuilder.create().if_(Bool.notEquals(lhs, rhs)); - } - - public static BlockBuilder objEquals(final Object lhs, - final Object rhs) { - return StatementBuilder.create().if_(Bool.expr(Stmt.load(lhs).invoke("equals", rhs))); - } - - public static BlockBuilder safeObjEquals(final Object lhs, - final Object rhs) { - return StatementBuilder.create().if_(Bool.expr(Bool.and(Bool.isNotNull(lhs), - Bool.expr(Stmt.load(lhs).invoke("equals", rhs))))); - } - - public static BlockBuilder objNotEquals(final Object lhs, - final Object rhs) { - return StatementBuilder.create().if_(Bool.notExpr(Bool.expr(Stmt.load(lhs).invoke("equals", rhs)))); - } - - public static BlockBuilder safeObjNotEquals(final Object lhs, - final Object rhs) { - return StatementBuilder.create().if_( - Bool.expr(Bool.and(Bool.isNotNull(lhs), - Bool.expr(Bool.notExpr(Stmt.load(lhs).invoke("equals", rhs)))))); - } - - public static BlockBuilder instanceOf(final Object lhs, - final Class type) { - - return instanceOf(lhs, MetaClassFactory.get(type)); - } - - public static BlockBuilder instanceOf(final Object lhs, - final MetaClass type) { - return StatementBuilder.create().if_(Bool.instanceOf(lhs, type)); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/Implementations.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/Implementations.java deleted file mode 100644 index ea50962a00a..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/Implementations.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.util; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.StringStatement; -import org.jboss.errai.codegen.Variable; -import org.jboss.errai.codegen.builder.BlockBuilder; -import org.jboss.errai.codegen.builder.ClassStructureBuilder; -import org.jboss.errai.codegen.builder.ContextualStatementBuilder; -import org.jboss.errai.codegen.builder.StatementEnd; -import org.jboss.errai.codegen.builder.impl.ClassBuilder; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; - -/** - * @author Mike Brock - */ -public class Implementations { - public static ClassStructureBuilder implement(final Class clazz) { - return ClassBuilder.define(clazz.getPackage().getName() + "." + clazz.getSimpleName() + "Impl") - .publicScope() - .implementsInterface(clazz) - .body(); - } - - public static ClassStructureBuilder implement(final Class clazz, - final String implClassName) { - return ClassBuilder.define(clazz.getPackage().getName() + "." + implClassName) - .publicScope() - .implementsInterface(clazz) - .body(); - } - - public static ClassStructureBuilder implement(final Class clazz, - final String implPackageName, - final String implClassName) { - return ClassBuilder.define(implPackageName + "." + implClassName) - .publicScope() - .implementsInterface(clazz) - .body(); - } - - /** - * Creates a builder for a new class that extends the given superclass. The - * new class being built will be in the same package as the given superclass. - * - * @param superclass - * The class that the class being built extends. - * @param implClassName - * The simple name (no package prefix) of the new class to be built. - * - * @return an instance of the {@link ClassStructureBuilder} for building the - * extended class - */ - public static ClassStructureBuilder extend(final Class superclass, final String implClassName) { - return ClassBuilder.define(superclass.getPackage().getName() + "." + implClassName, superclass) - .publicScope() - .body(); - } - - public static void autoInitializedField(final ClassStructureBuilder builder, - final MetaClass type, - final String name, - final Class implementation) { - - autoInitializedField(builder, type, name, MetaClassFactory.get(implementation)); - } - - public static void autoInitializedField(final ClassStructureBuilder builder, - final MetaClass type, - final String name, - MetaClass implementation) { - - implementation = MetaClassFactory.parameterizedAs(implementation, type.getParameterizedType()); - - builder.privateField(name, type) - .initializesWith(Stmt.newObject(implementation)).finish(); - } - - public static StringBuilderBuilder newStringBuilder() { - return newStringBuilder(64); - } - - public static StringBuilderBuilder newStringBuilder(final int length) { - final ContextualStatementBuilder statementBuilder - = Stmt.nestedCall(Stmt.newObject(StringBuilder.class).withParameters(length)); - - return new StringBuilderBuilder() { - - @Override - public StringBuilderBuilder append(final Object statement) { - statementBuilder.invoke("append", statement); - return this; - } - - String generatedCache; - - @Override - public String generate(final Context context) { - if (generatedCache != null) return generatedCache; - return generatedCache = statementBuilder.generate(context); - } - - @Override - public MetaClass getType() { - return statementBuilder.getType(); - } - }; - } - - - - public static interface StringBuilderBuilder extends Statement { - public StringBuilderBuilder append(Object statement); - } - - public static BlockBuilder autoForLoop(final String varName, final Statement value) { - return Stmt.for_(Stmt.declareVariable(int.class).named("i").initializeWith(0), - Bool.lessThan(Variable.get("i"), value), - new StringStatement(varName + "++", null)); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/PrettyPrinter.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/PrettyPrinter.java deleted file mode 100644 index a69212a7d6c..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/PrettyPrinter.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.util; - -import org.mvel2.util.ParseTools; - -/** - * @author Mike Brock - */ -public class PrettyPrinter { - public static String prettyPrintJava(final String input) { - final StringBuilder out = new StringBuilder(2048); - StringBuilder lineBuffer = new StringBuilder(120); - - final char[] expr = input.toCharArray(); - - int indentLevel = 0; - final int statementIndent = 0; - - for (int i = 0; i < expr.length; i++) { - switch (expr[i]) { - case '{': - writeToBuffer(out, lineBuffer.append("{ "), indentLevel++, statementIndent); - lineBuffer = new StringBuilder(120); - break; - - case '}': - writeToBuffer(out, lineBuffer, --indentLevel, statementIndent); - lineBuffer = new StringBuilder(120).append(" }"); - break; - - case '"': - case '\'': - final int start = i; - i = ParseTools.balancedCapture(expr, i, expr[i]); - lineBuffer.append(expr, start, i - start + 1); - break; - - case '\n': - writeToBuffer(out, lineBuffer, indentLevel, statementIndent); - out.append('\n'); - lineBuffer = new StringBuilder(120); - break; - - case ',': - lineBuffer.append(", "); - break; - - - default: - if (Character.isWhitespace(expr[i])) { - lineBuffer.append(" "); - i = skipWhitespace(expr, i) - 1; - } - else { - lineBuffer.append(expr[i]); - } - } - } - - if (lineBuffer.length() != 0) { - writeToBuffer(out, lineBuffer, indentLevel, statementIndent); - } - - return compactinate(out.toString()); - } - - private static void writeToBuffer(final StringBuilder out, final StringBuilder lineBuffer, - final int indentLevel, final int statementIndent) { - final String trimmedLineBuffer = lineBuffer.toString().trim(); - - if (trimmedLineBuffer.isEmpty()) { - return; - } - - out.append(pad((indentLevel + statementIndent) * 2)).append(trimmedLineBuffer); - } - - private static String compactinate(final String str) { - final char[] expr = str.toCharArray(); - final StringBuilder buf = new StringBuilder(expr.length); - boolean newLine = false; - for (int i = 0; i < expr.length; i++) { - switch (expr[i]) { - case '"': - case '\'': - final int start = i; - buf.append(expr, start, (i = ParseTools.balancedCapture(expr, i, expr[i])) - start + 1); - break; - case '\n': - newLine = true; - buf.append('\n'); - break; - - default: - if (Character.isWhitespace(expr[i])) { - buf.append(" "); - if (!newLine) { - i = skipWhitespace(expr, i) - 1; - } - } - else { - newLine = false; - buf.append(expr[i]); - } - } - } - return buf.toString().trim(); - } - - private static String pad(final int amount) { - if (amount <= 0) return ""; - - final char[] pad = new char[amount]; - for (int i = 0; i < amount; i++) { - pad[i] = ' '; - } - return new String(pad); - } - - public static int skipWhitespace(final char[] expr, int cursor) { - Skip: - while (cursor != expr.length) { - switch (expr[cursor]) { - case '\r': - cursor++; - continue; - - default: - if (!Character.isWhitespace(expr[cursor])) break Skip; - - } - cursor++; - } - return cursor; - - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/PrivateAccessType.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/PrivateAccessType.java deleted file mode 100644 index 0c5a232288b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/PrivateAccessType.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.util; - -/** - * @author Mike Brock - */ -public enum PrivateAccessType { - Read, Write, Both -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/PrivateAccessUtil.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/PrivateAccessUtil.java deleted file mode 100644 index 3e76b377ae9..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/PrivateAccessUtil.java +++ /dev/null @@ -1,234 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.util; - -import java.util.HashMap; -import java.util.Map; - -import org.jboss.errai.codegen.Modifier; -import org.jboss.errai.codegen.builder.ClassStructureBuilder; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaConstructor; -import org.jboss.errai.codegen.meta.MetaField; -import org.jboss.errai.codegen.meta.MetaMethod; -import org.jboss.errai.codegen.meta.MetaParameter; - -/** - * Utility class with methods that generate code to access private, default - * access ("package private"), and protected methods and fields in arbitrary - * classes. Each generator allows the choice of generating Java Reflection code - * (for use on the server side) or JSNI code (for use on the client side). - * - * @author Mike Brock - * @author Jonathan Fuerth - * @author Christian Sadilek - */ -public class PrivateAccessUtil { - private static final Map PRIVATE_MEMBER_ACCESSORS - = new HashMap(); - - static { - PRIVATE_MEMBER_ACCESSORS.put("reflection", new ReflectionPrivateMemberAccessor()); - } - - public static void registerPrivateMemberAccessor(final String type, final PrivateMemberAccessor accessor) { - PRIVATE_MEMBER_ACCESSORS.put(type, accessor); - } - - public static void addPrivateAccessStubs(final String type, - final ClassStructureBuilder classBuilder, - final MetaField f) { - addPrivateAccessStubs(PrivateAccessType.Both, type, classBuilder, f); - } - - /** - * Generates methods for accessing a private field using either JSNI or Java - * Reflection. The generated methods will be private and static. - * - * @param accessType - * Whether to generate a read method, a write method, or both. - * @param type - * The type of accessors to use (ie. "reflection" or "jsni"). - * @param classBuilder - * The class builder to add the generated methods to. - * @param f - * The field the generated accessors read and write. - */ - public static void addPrivateAccessStubs(final PrivateAccessType accessType, - final String type, - final ClassStructureBuilder classBuilder, - final MetaField f) { - addPrivateAccessStubs(accessType, type, classBuilder, f, new Modifier[]{Modifier.Static}); - } - - /** - * Generates methods for accessing a private field using either JSNI or Java - * Reflection. The generated methods will be private. - * - * @param accessType - * Whether to generate a read method, a write method, or both. - * @param accessorType - * The type of accessors to use (ie. "reflection" or "jsni"). - * @param classBuilder - * The class builder to add the generated methods to. - * @param f - * The field the generated accessors read and write. - * @param modifiers - * The modifiers on the generated method, for example - * {@link Modifier#Final} or {@link Modifier#Synchronized}. Never - * specify {@code Modifier.JSNI}; it is added automatically when - * needed. - */ - public static void addPrivateAccessStubs(final PrivateAccessType accessType, - final String accessorType, - final ClassStructureBuilder classBuilder, - final MetaField f, - Modifier[] modifiers) { - final MetaClass type = f.getType(); - - final boolean read = accessType == PrivateAccessType.Read || accessType == PrivateAccessType.Both; - final boolean write = accessType == PrivateAccessType.Write || accessType == PrivateAccessType.Both; - - final PrivateMemberAccessor privateMemberAccessor - = PRIVATE_MEMBER_ACCESSORS.get(accessorType); - - if (privateMemberAccessor == null) { - throw new IllegalArgumentException("unknown accessor type: " + accessorType); - } - - if (read) { - privateMemberAccessor.createReadableField(type, classBuilder, f, modifiers); - } - - if (write) { - privateMemberAccessor.createWritableField(type, classBuilder, f, modifiers); - } - } - - /** - * Generates methods for accessing a nonpublic constructor using either JSNI or - * Java Reflection. The generated method will be private and static. The name - * of the generated method can be discovered by calling - * {@link #getPrivateMethodName(MetaMethod)}. - * - * @param accessorType - * The type of accessors to use (ie. "reflection" or "jsni"). - * @param classBuilder - * The class builder to add the generated method to. - * @param m - * The constructor the generated method will invoke - */ - public static void addPrivateAccessStubs(final String accessorType, - final ClassStructureBuilder classBuilder, - final MetaConstructor m) { - - final PrivateMemberAccessor privateMemberAccessor - = PRIVATE_MEMBER_ACCESSORS.get(accessorType); - - if (privateMemberAccessor == null) { - throw new IllegalArgumentException("unknown accessor type: " + accessorType); - } - - privateMemberAccessor.makeConstructorAccessible(classBuilder, m); - } - - /** - * Generates methods for accessing a nonpublic method using either JSNI or - * Java Reflection. The generated method will be private and static. The name - * of the generated method can be discovered by calling - * {@link #getPrivateMethodName(MetaMethod)}. - * - * @param accessorType - * The type of accessors to use (ie. "reflection" or "jsni"). - * @param classBuilder - * The class builder to add the generated method to. - * @param m - * The nonpublic method the generated method will invoke - */ - public static void addPrivateAccessStubs(final String accessorType, - final ClassStructureBuilder classBuilder, - final MetaMethod m) { - addPrivateAccessStubs(accessorType, classBuilder, m, new Modifier[]{Modifier.Static}); - } - - /** - * Generates methods for accessing a nonpublic method using either JSNI or Java - * Reflection. The generated method will be private and static. - * - * @param accessorType - * The type of accessors to use (ie. "reflection" or "jsni"). - * @param classBuilder - * The class builder to add the generated method to. - * @param m - * The method the generated accessors read and write. - * @param modifiers - * The modifiers on the generated method, for example - * {@link Modifier#Final} or {@link Modifier#Synchronized}. Never - * specify {@code Modifier.JSNI}; it is added automatically when - * needed. - */ - public static void addPrivateAccessStubs(final String accessorType, - final ClassStructureBuilder classBuilder, - final MetaMethod m, - final Modifier[] modifiers) { - - - final PrivateMemberAccessor privateMemberAccessor - = PRIVATE_MEMBER_ACCESSORS.get(accessorType); - - if (privateMemberAccessor == null) { - throw new IllegalArgumentException("unknown accessor type: " + accessorType); - } - - privateMemberAccessor.makeMethodAccessible(classBuilder, m, modifiers); - } - - public static String getPrivateFieldAccessorName(final MetaField field) { - return field.getDeclaringClass().getName() - + "_" + getTypeName(field.getType()) - + "_" + field.getName(); - } - - public static String getPrivateMethodName(final MetaMethod method) { - final MetaClass declaringClass = method.getDeclaringClass(); - String name = declaringClass.getName() + "_" + method.getName(); - - if (method.getParameters() != null) { - for (final MetaParameter p : method.getParameters()) { - name += "_" + getTypeName(p.getType()); - } - } - - return name; - } - - private static String getTypeName(final MetaClass type) { - if (type.isArray()) { - return type.getName().replace("[]", "_array"); - } else { - return type.getName(); - } - } - - public static String condensify(String name) { - return name.replace('.', '_').replace('$', '_'); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/PrivateMemberAccessor.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/PrivateMemberAccessor.java deleted file mode 100644 index 23c3bb95ed5..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/PrivateMemberAccessor.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.util; - -import org.jboss.errai.codegen.Modifier; -import org.jboss.errai.codegen.builder.ClassStructureBuilder; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaConstructor; -import org.jboss.errai.codegen.meta.MetaField; -import org.jboss.errai.codegen.meta.MetaMethod; - -/** - * @author Mike Brock - */ -public interface PrivateMemberAccessor { - public void createWritableField(MetaClass type, - ClassStructureBuilder classBuilder, - MetaField field, - Modifier[] modifiers); - - public void createReadableField(MetaClass type, - ClassStructureBuilder classBuilder, - MetaField field, - Modifier[] modifiers); - - public void makeMethodAccessible(final ClassStructureBuilder classBuilder, - final MetaMethod field, - Modifier[] modifiers); - - public void makeConstructorAccessible(final ClassStructureBuilder classBuilder, - final MetaConstructor field); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/ProxyUtil.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/ProxyUtil.java deleted file mode 100644 index 8e18b954651..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/ProxyUtil.java +++ /dev/null @@ -1,438 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.util; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.context.Dependent; -import javax.inject.Singleton; - -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.Multimap; -import com.google.common.reflect.TypeToken; -import com.google.gwt.core.ext.GeneratorContext; -import org.jboss.errai.codegen.BlockStatement; -import org.jboss.errai.codegen.BooleanOperator; -import org.jboss.errai.codegen.Parameter; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.StringStatement; -import org.jboss.errai.codegen.Variable; -import org.jboss.errai.codegen.builder.AnonymousClassStructureBuilder; -import org.jboss.errai.codegen.builder.ElseBlockBuilder; -import org.jboss.errai.codegen.builder.impl.BooleanExpressionBuilder; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.meta.MetaMethod; -import org.jboss.errai.codegen.meta.MetaParameter; -import org.jboss.errai.common.client.api.ErrorCallback; -import org.jboss.errai.common.client.api.RemoteCallback; -import org.jboss.errai.common.client.api.interceptor.FeatureInterceptor; -import org.jboss.errai.common.client.api.interceptor.InterceptedCall; -import org.jboss.errai.common.client.api.interceptor.InterceptsRemoteCall; -import org.jboss.errai.common.client.api.interceptor.RemoteCallContext; -import org.jboss.errai.common.client.util.AsyncBeanFactory; -import org.jboss.errai.common.client.util.CreationalCallback; -import org.jboss.errai.common.metadata.RebindUtils; - -/** - * Utilities to avoid redundant code for proxy generation. - * - * @author Christian Sadilek - * @author Mike Brock - */ -public abstract class ProxyUtil { - - private static final String IOC_MODULE_NAME = "org.jboss.errai.ioc.Container"; - - private ProxyUtil() {} - - /** - * Generates the {@link org.jboss.errai.common.client.api.interceptor.CallContext} for method - * interception. Ignores annotations in non-translatable packages. - * - * @param callContextType - * the type of {@link org.jboss.errai.common.client.api.interceptor.RemoteCallContext} to - * use. - * @param proxyClass - * the declaring proxy class - * @param method - * the method that is being proxied. - * @param proceed - * the logic that should be invoked if - * {@link org.jboss.errai.common.client.api.interceptor.CallContext#proceed()} is called. - * @param interceptors - * a list of interceptors to use - * @return statement representing an anonymous implementation of the provided - * {@link org.jboss.errai.common.client.api.interceptor.CallContext} - */ - public static AnonymousClassStructureBuilder generateProxyMethodCallContext( - final GeneratorContext context, - final Class callContextType, - final MetaClass proxyClass, final MetaMethod method, - final Statement proceed, final List> interceptors) { - - final Set translatablePackages = RebindUtils.findTranslatablePackages(context); - - return Stmt.newObject(callContextType).extend() - .publicOverridesMethod("getMethodName") - .append(Stmt.load(method.getName()).returnValue()) - .finish() - .publicOverridesMethod("getReturnType") - .append(Stmt.load(method.getReturnType()).returnValue()) - .finish() - .publicOverridesMethod("getAnnotations") - .append(Stmt.load(filter(method.getAnnotations(), translatablePackages)).returnValue()) - .finish() - .publicOverridesMethod("getTypeAnnotations") - .append( - Stmt.load(filter(method.getDeclaringClass().getAnnotations(), translatablePackages)).returnValue()) - .finish() - .publicOverridesMethod("proceed") - .append(generateInterceptorStackProceedMethod(context, callContextType, proceed, interceptors)) - .append(Stmt.load(null).returnValue()) - .finish() - .publicOverridesMethod("proceed", Parameter.of(RemoteCallback.class, "interceptorCallback", true)) - .append(Stmt.declareVariable(RemoteCallback.class).asFinal().named("providedCallback").initializeWith( - Stmt.loadStatic(proxyClass, "this").loadField("remoteCallback"))) - .append( - Stmt.loadVariable("remoteCallback").assignValue(Stmt.newObject(RemoteCallback.class).extend() - .publicOverridesMethod("callback", Parameter.of(Object.class, "response")) - .append(Stmt.declareVariable(RemoteCallback.class).named("intCallback") - .initializeWith(Stmt.loadVariable("interceptorCallback"))) - .append(StringStatement.of("setResult(response)")) - .append(Stmt.loadVariable("intCallback").invoke("callback", - StringStatement.of("getResult()", Object.class))) - .append(Stmt.loadVariable("providedCallback").invoke("callback", - StringStatement.of("getResult()", Object.class))) - .finish() - .finish()) - ) - .append(Stmt.loadVariable("this").invoke("proceed")) - .finish() - .publicOverridesMethod("proceed", Parameter.of(RemoteCallback.class, "interceptorCallback"), - Parameter.of(ErrorCallback.class, "interceptorErrorCallback", true)) - .append( - Stmt.declareVariable(ErrorCallback.class).asFinal().named("providedErrorCallback").initializeWith( - Stmt.loadStatic(proxyClass, "this").loadField("errorCallback"))) - .append( - Stmt.loadVariable("errorCallback").assignValue( - Stmt.newObject(ErrorCallback.class).extend() - .publicOverridesMethod("error", Parameter.of(Object.class, "message"), - Parameter.of(Throwable.class, "throwable")) - .append( - Stmt.loadVariable("interceptorErrorCallback").invoke("error", Variable.get("message"), - Variable.get("throwable"))) - .append( - Stmt.if_( - BooleanExpressionBuilder.create( - StringStatement.of("getResult()", Object.class), BooleanOperator.NotEquals, Stmt - .loadLiteral(null))) - .append( - Stmt.loadVariable("remoteCallback").invoke("callback", - StringStatement.of("getResult()", Object.class))) - .append(Stmt.load(false).returnValue()) - .finish() - .elseif_( - BooleanExpressionBuilder.create( - Stmt.loadVariable("providedErrorCallback"), BooleanOperator.NotEquals, Stmt - .loadLiteral(null))) - .append( - Stmt.nestedCall( - Stmt.loadVariable("providedErrorCallback").invoke("error", - Variable.get("message"), - Variable.get("throwable"))) - .returnValue()) - .finish()) - .append(Stmt.load(true).returnValue()) - .finish() - .finish()) - ) - .append(Stmt.loadVariable("this").invoke("proceed", Variable.get("interceptorCallback"))) - .finish(); - } - - private static Statement generateInterceptorStackProceedMethod( - final GeneratorContext context, - final Class callContextType, - final Statement proceed, final List> interceptors) { - final BlockStatement proceedLogic = new BlockStatement(); - proceedLogic.addStatement(Stmt.loadVariable("status").invoke("proceed")); - - ElseBlockBuilder interceptorStack = - If.isNull(Stmt.loadVariable("status").invoke("getNextInterceptor"))._(proceed).finish(); - - for (final Class interceptor : interceptors) { - interceptorStack = interceptorStack.elseif_(Bool.equals( - Stmt.loadVariable("status").invoke("getNextInterceptor"), interceptor)) - .append(Stmt.declareFinalVariable("ctx", callContextType, Stmt.loadVariable("this"))) - .append( - Stmt.declareVariable(CreationalCallback.class).asFinal().named("icc") - .initializeWith( - Stmt.newObject(CreationalCallback.class).extend() - .publicOverridesMethod("callback", Parameter.of(Object.class, "beanInstance", true)) - .append(Stmt.loadVariable("status").invoke("setProceeding", false)) - .append( - Stmt.castTo(interceptor, Stmt.loadVariable("beanInstance")).invoke("aroundInvoke", - Variable.get("ctx"))) - .append( - If.cond(Bool.and( - Bool.notExpr(Stmt.loadVariable("status").invoke("isProceeding")), - Bool.equals(Stmt.loadLiteral(interceptor), Stmt.loadVariable("status").invoke("getNextInterceptor")))) - .append( - Stmt.loadVariable("remoteCallback").invoke("callback", - Stmt.loadVariable("ctx").invoke("getResult"))) - .finish()) - .finish() // finish the method override body - .finish() // finish the anonymous CreationalCallback class body - )) - .append(generateAsyncInterceptorCreation(context, interceptor)) - .finish(); - } - proceedLogic.addStatement(interceptorStack.else_().finish()); - return proceedLogic; - } - - /** - * Generates the code that will create the interceptor and then invoke the callback when done. If - * IOC is available *and* the interceptor is a managed bean, then the IOC bean manager will be - * used to load the interceptor. - * - * @param context - * @param interceptor - */ - private static Statement generateAsyncInterceptorCreation(final GeneratorContext context, - final Class interceptor) { - if (RebindUtils.isModuleInherited(context, IOC_MODULE_NAME) && isManagedBean(interceptor)) { - // Note: for the IOC path, generate the code via StringStatement because we - // need to make sure that IOC is an optional dependency. This should probably - // be replaced with some sort of pluggable model instead (where a Statement can - // be provided by some Provider in the IOC module itself maybe). - final StringBuilder builder = new StringBuilder(); - builder.append("org.jboss.errai.ioc.client.container.IOC.getAsyncBeanManager().lookupBeans(") - .append(interceptor.getSimpleName()) - .append(".class).iterator().next().getInstance(icc)"); - return new StringStatement(builder.toString()); - } - else { - return Stmt.invokeStatic(AsyncBeanFactory.class, "createBean", - Stmt.newObject(interceptor), Variable.get("icc")); - } - } - - /** - * A utility class that provides a list of interceptors for a given remote interface and method. - */ - public static class InterceptorProvider { - // Maps a feature interceptor annotation (i.e. RequiredRoles, RestrictAccess) to a list of - // interceptors that should be triggered when this annotation is present. - final Multimap, Class> featureInterceptors = ArrayListMultimap.create(); - - // Maps a remote interface type to a list of interceptors that should be triggered for all - // methods of this type. - final Multimap, Class> standaloneInterceptors = ArrayListMultimap.create(); - - public InterceptorProvider(final Collection featureInterceptors, final Collection standaloneInterceptors) { - setFeatureInterceptors(featureInterceptors); - setStandaloneInterceptors(standaloneInterceptors); - } - - private void setFeatureInterceptors(final Collection featureInterceptors) { - for (final MetaClass featureInterceptor : featureInterceptors) { - final Class[] annotations = - featureInterceptor.getAnnotation(FeatureInterceptor.class).value(); - - for (int i = 0; i < annotations.length; i++) { - this.featureInterceptors.put(annotations[i], featureInterceptor.asClass()); - } - } - } - - private void setStandaloneInterceptors(final Collection standaloneInterceptors) { - for (final MetaClass interceptorClass : standaloneInterceptors) { - final InterceptsRemoteCall interceptor = interceptorClass.getAnnotation(InterceptsRemoteCall.class); - final Class[] intercepts = interceptor.value(); - for (final Class intercept : intercepts) { - this.standaloneInterceptors.put(intercept, interceptorClass.asClass()); - } - } - } - - /** - * Returns the interceptors for the provided proxy type and method. - * - * @param type - * the remote interface - * @param method - * the remote method - * - * @return the list of interceptors that should be triggered when invoking the provided proxy - * method on the provided type, never null. - */ - public List> getInterceptors(final MetaClass type, final MetaMethod method) { - final List> interceptors = new ArrayList<>(); - - InterceptedCall interceptedCall = method.getAnnotation(InterceptedCall.class); - if (interceptedCall == null) { - interceptedCall = type.getAnnotation(InterceptedCall.class); - } - - if (interceptedCall == null) { - interceptors.addAll(standaloneInterceptors.get(type.asClass())); - } - else { - for (final Class clazz : interceptedCall.value()) { - interceptors.add(clazz); - } - } - - for (final Class annotation : featureInterceptors.keySet()) { - if (type.isAnnotationPresent(annotation) || method.isAnnotationPresent(annotation)) { - interceptors.addAll(featureInterceptors.get(annotation)); - } - } - - return interceptors; - } - } - - /** - * Returns true if the given bean is an explicitely managed bean (meaning it is annotated in some - * way). - * - * @param interceptor - */ - private static boolean isManagedBean(final Class interceptor) { - if (interceptor.getAnnotation(ApplicationScoped.class) != null) - return true; - if (interceptor.getAnnotation(Singleton.class) != null) - return true; - if (interceptor.getAnnotation(Dependent.class) != null) - return true; - return false; - } - - public static boolean shouldProxyMethod(final MetaMethod method) { - final String methodName = method.getName(); - - return !method.isFinal() && !method.isStatic() && !method.isPrivate() && !methodName.equals("hashCode") - && !methodName.equals("equals") && !methodName.equals("toString") && !methodName.equals("clone") - && !methodName.equals("finalize"); - } - - public static String createCallSignature(final MetaMethod m) { - final StringBuilder append = new StringBuilder(m.getName()).append(':'); - for (final MetaParameter parm : m.getParameters()) { - append.append(parm.getType().getCanonicalName()).append(':'); - } - return append.toString(); - } - - public static String createCallSignature(final Class referenceClass, final Method m) { - final TypeToken resolver = TypeToken.of(referenceClass); - final StringBuilder append = new StringBuilder(m.getName()).append(':'); - for (final Type c : m.getGenericParameterTypes()) { - final TypeToken resolvedParamType = resolver.resolveType(c); - append.append(resolvedParamType.getRawType().getCanonicalName()).append(':'); - } - return append.toString(); - } - - public static boolean isMethodInInterface(final Class iface, final Method member) { - try { - if (iface.getMethod(member.getName(), member.getParameterTypes()) != null) - return true; - } - catch (final NoSuchMethodException e) { - } - return false; - } - - public static boolean isMethodInInterface(final MetaClass iface, final MetaMethod member) { - if (iface.getMethod(member.getName(), Arrays.stream(member.getParameters()).map(p -> p.getType()).toArray(MetaClass[]::new)) != null) - return true; - return false; - } - - /** - * Generates a valid return statement for the provided method. - * - * @param method - * @return return statement for the provided method - */ - public static Statement generateProxyMethodReturnStatement(final MetaMethod method) { - Statement returnStatement = null; - if (!method.getReturnType().equals(MetaClassFactory.get(void.class))) { - - // if it's a Number and not a BigDecimal or BigInteger - if (MetaClassFactory.get(Number.class).isAssignableFrom(method.getReturnType().asBoxed()) - && method.getReturnType().asUnboxed().getFullyQualifiedName().indexOf('.') == -1) { - - if (MetaClassFactory.get(Double.class).isAssignableFrom(method.getReturnType().asBoxed())) { - returnStatement = Stmt.load(0.0).returnValue(); - } - else if (MetaClassFactory.get(Float.class).isAssignableFrom(method.getReturnType().asBoxed())) { - returnStatement = Stmt.load(0f).returnValue(); - } - else if (MetaClassFactory.get(Long.class).isAssignableFrom(method.getReturnType().asBoxed())) { - returnStatement = Stmt.load(0l).returnValue(); - } - else { - returnStatement = Stmt.load(0).returnValue(); - } - } - else if (MetaClassFactory.get(char.class).equals(method.getReturnType())) { - returnStatement = Stmt.load(0).returnValue(); - } - else if (MetaClassFactory.get(Boolean.class).isAssignableFrom(method.getReturnType().asBoxed())) { - returnStatement = Stmt.load(false).returnValue(); - } - else { - returnStatement = Stmt.load(null).returnValue(); - } - } - return returnStatement; - } - - private static Annotation[] filter(final Annotation[] raw, final Set packages) { - final Annotation[] firstPass = new Annotation[raw.length]; - int j = 0; - for (int i = 0; i < raw.length; i++) { - if (packages.contains(raw[i].annotationType().getPackage().getName())) { - firstPass[j++] = raw[i]; - } - } - - final Annotation[] retVal = new Annotation[j]; - for (int i = 0; i < j; i++) { - retVal[i] = firstPass[i]; - } - - return retVal; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/QuickDeps.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/QuickDeps.java deleted file mode 100644 index 2fab7c34c8f..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/QuickDeps.java +++ /dev/null @@ -1,322 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.util; - -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.net.URLDecoder; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.mvel2.util.ParseTools; - -/** - * @author Mike Brock - */ -public class QuickDeps { - private static final Set RESERVED_KEYWORDS = new HashSet() { - { - add("abstract"); - add("assert"); - add("boolean"); - add("break"); - add("byte"); - add("case"); - add("catch"); - add("char"); - add("class"); - add("const"); - add("continue"); - add("default"); - add("do"); - add("double"); - add("else"); - add("enum"); - add("extends"); - add("final"); - add("finally"); - add("float"); - add("for"); - add("goto"); - add("if"); - add("implements"); - add("import"); - add("instanceof"); - add("int"); - add("interface"); - add("long"); - add("native"); - add("new"); - add("package"); - add("private"); - add("protected"); - add("public"); - add("return"); - add("short"); - add("static"); - add("strictfp"); - add("super"); - add("switch"); - add("synchronized"); - add("this"); - add("throw"); - add("throws"); - add("transient"); - add("try"); - add("void"); - add("volatile"); - add("while"); - - add("false"); - add("null"); - add("true"); - } - }; - - private static final Predicate DEFAULT_PREDICATE = new Predicate() { - @Override - public boolean processPackage(String packageName) { - return true; - } - - @Override - public boolean processClass(String className) { - return true; - } - }; - - public static Set getQuickTypeDependencyList(final String javaSource, ClassLoader classLoader) { - return getQuickTypeDependencyList(javaSource, classLoader, DEFAULT_PREDICATE); - } - - public static Set getQuickTypeDependencyList(final String javaSource, ClassLoader classLoader, Predicate predicate) { - try { - if (classLoader == null) { - classLoader = Thread.currentThread().getContextClassLoader(); - } - - final IdentifierTokenizer identifierTokenizer = new IdentifierTokenizer(javaSource); - - final Map imports = new HashMap(32); - final Set wildcardPackages = new HashSet(32); - wildcardPackages.add("java.lang"); - - final Set usedTypes = new HashSet(100); - - boolean firstClass = true; - String clazzName = null; - String packageName = ""; - - String token; - while ((token = identifierTokenizer.nextToken()) != null) { - if (RESERVED_KEYWORDS.contains(token)) { - if ("import".equals(token)) { - if ((token = identifierTokenizer.nextToken()).charAt(token.length() - 1) == '*') { - wildcardPackages.add(token.substring(0, token.lastIndexOf('.'))); - } - else { - imports.put(token, token); - imports.put(token.substring(token.lastIndexOf('.') + 1), token); - } - } - else if ("package".equals(token)) { - wildcardPackages.add(token = identifierTokenizer.nextToken()); - if (!predicate.processPackage(token)) { - return Collections.emptySet(); - } - - packageName = token.concat("."); - - } - else if ("class".equals(token)) { - if (firstClass) { - firstClass = false; - final String fqcn = packageName + (clazzName = identifierTokenizer.nextToken()); - - if (!predicate.processClass(fqcn)) { - return Collections.emptySet(); - } - - usedTypes.add(fqcn); - } - else { - final String innerClassName = packageName - .concat(clazzName) - .concat("$") - .concat(token = identifierTokenizer.nextToken()); - - usedTypes.add(innerClassName); - imports.put(token, innerClassName); - } - } - continue; - } - - if (token.endsWith(".class")) { - token = token.substring(0, token.length() - 6); - } - /** - * This handles the case where there's whitespace or a comment after the union operator. - */ - else if (token.charAt(token.length() - 1) == '.') { - token = token.substring(0, token.length() - 1); - } - - if (imports.containsKey(token)) { - usedTypes.add(imports.get(token)); - } - else { - wildcardMatch(classLoader, imports, wildcardPackages, usedTypes, token); - } - } - - return usedTypes; - } - catch (IOException e) { - throw new RuntimeException("error reading filesystem", e); - } - } - - private static void wildcardMatch(final ClassLoader classLoader, - final Map imports, - final Set wildcardPackages, - final Set usedTypes, - final String name) throws IOException { - - for (final String pkg : wildcardPackages) { - - final String fqcn = pkg.concat(".").concat(name); - final String slashified = fqcn.replace('.', '/'); - final String source = slashified.concat(".java"); - final String clazz = slashified.concat(".class"); - - URL url; - if ((url = classLoader.getResource(source)) != null - || (url = classLoader.getResource(clazz)) != null) { - - String urlFile = URLDecoder.decode(url.getFile(), "UTF-8"); - - int split; - if ((split = urlFile.lastIndexOf('!')) != -1) { - urlFile = urlFile.substring(split + 2); - } - - final String path = URLDecoder.decode(new File(urlFile).getCanonicalFile().toURI().getPath(), "UTF-8"); - System.out.println("urlFile: " + urlFile); - System.out.println(" to: " + path); - System.out.println(" source: " + source); - System.out.println(" clazz: " + clazz); - - if (urlFile.endsWith(source) || urlFile.endsWith(clazz)) { - if (split != -1 || path.equalsIgnoreCase(urlFile)) { - imports.put(fqcn, fqcn); - imports.put(name, fqcn); - usedTypes.add(fqcn); - } - return; - } - } - } - } - - private static class IdentifierTokenizer { - private final String expr; - private int i; - private int startToken; - private boolean tokenCapture; - - private IdentifierTokenizer(final String expr) { - this.expr = expr; - } - - public String nextToken() { - char c; - for (; i < expr.length(); i++) { - switch (c = expr.charAt(i)) { - case '"': - case '\'': - if (i < expr.length()) { - i = captureStringLiteral(c, expr, i, expr.length()) + 1; - } - break; - - case '/': - if (tokenCapture) { - tokenCapture = false; - return expr.substring(startToken, i).trim(); - } - - if (i < expr.length() && expr.charAt(i + 1) == '*') { - i += 2; - while (i < expr.length() && !(c == '*' && expr.charAt(i + 1) == '/')) { - c = expr.charAt(++i); - } - i++; - } - else if (expr.charAt(i + 1) == '/') { - while (i < expr.length() && c != '\n') { - c = expr.charAt(++i); - } - } - break; - - default: - if (ParseTools.isIdentifierPart(c) - || c == '.' - || (c == '*' && expr.charAt(i - 1) == '.')) { - - if (!tokenCapture) { - startToken = i; - tokenCapture = true; - } - } - else if (tokenCapture) { - tokenCapture = false; - return expr.substring(startToken, i); - } - } - } - - return null; - } - } - - public static int captureStringLiteral(final char type, final String expr, int cursor, final int end) { - while (++cursor < end && expr.charAt(cursor) != type) { - if (expr.charAt(cursor) == '\\') cursor++; - } - - if (cursor >= end || expr.charAt(cursor) != type) { - throw new RuntimeException("unterminated string literal"); - } - - return cursor; - } - - public static interface Predicate { - public boolean processPackage(String packageName); - public boolean processClass(String className); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/ReflectionPrivateMemberAccessor.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/ReflectionPrivateMemberAccessor.java deleted file mode 100644 index 9f2450d0323..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/ReflectionPrivateMemberAccessor.java +++ /dev/null @@ -1,385 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.util; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; - -import org.jboss.errai.codegen.Cast; -import org.jboss.errai.codegen.DefParameters; -import org.jboss.errai.codegen.Modifier; -import org.jboss.errai.codegen.Parameter; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.builder.BlockBuilder; -import org.jboss.errai.codegen.builder.CatchBlockBuilder; -import org.jboss.errai.codegen.builder.ClassStructureBuilder; -import org.jboss.errai.codegen.builder.ContextualStatementBuilder; -import org.jboss.errai.codegen.builder.MethodCommentBuilder; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.meta.MetaConstructor; -import org.jboss.errai.codegen.meta.MetaField; -import org.jboss.errai.codegen.meta.MetaMethod; - -/** - * @author Mike Brock - */ -public class ReflectionPrivateMemberAccessor implements PrivateMemberAccessor { - - private static final String JAVA_REFL_FLD_UTIL_METH = "_getAccessibleField"; - private static final String JAVA_REFL_METH_UTIL_METH = "_getAccessibleMethod"; - private static final String JAVA_REFL_CONSTRUCTOR_UTIL_METH = "_getAccessibleConstructor"; - - public static void createJavaReflectionFieldInitializerUtilMethod(final ClassStructureBuilder classBuilder) { - - if (classBuilder.getClassDefinition().getMethod(JAVA_REFL_FLD_UTIL_METH, Class.class, Field.class) != null) { - return; - } - - classBuilder.privateMethod(Field.class, JAVA_REFL_FLD_UTIL_METH).modifiers(Modifier.Static) - .parameters(DefParameters.of(Parameter.of(Class.class, "cls"), Parameter.of(String.class, "name"))) - .body() - ._(Stmt.try_() - ._(Stmt.declareVariable("fld", Stmt.loadVariable("cls").invoke("getDeclaredField", - Stmt.loadVariable("name")))) - ._(Stmt.loadVariable("fld").invoke("setAccessible", true)) - ._(Stmt.loadVariable("fld").returnValue()) - .finish() - .catch_(Throwable.class, "e") - ._(Stmt.loadVariable("e").invoke("printStackTrace")) - ._(Stmt.throw_(RuntimeException.class, Refs.get("e"))) - .finish()) - .finish(); - } - - public static void createJavaReflectionMethodInitializerUtilMethod( - final ClassStructureBuilder classBuilder) { - - if (classBuilder.getClassDefinition().getMethod(JAVA_REFL_METH_UTIL_METH, Class.class, String.class, Class[].class) != null) { - return; - } - - classBuilder.privateMethod(Method.class, JAVA_REFL_METH_UTIL_METH).modifiers(Modifier.Static) - .parameters(DefParameters.of(Parameter.of(Class.class, "cls"), Parameter.of(String.class, "name"), - Parameter.of(Class[].class, "parms"))) - .body() - ._(Stmt.try_() - ._(Stmt.declareVariable("meth", Stmt.loadVariable("cls").invoke("getDeclaredMethod", - Stmt.loadVariable("name"), Stmt.loadVariable("parms")))) - ._(Stmt.loadVariable("meth").invoke("setAccessible", true)) - ._(Stmt.loadVariable("meth").returnValue()) - .finish() - .catch_(Throwable.class, "e") - ._(Stmt.loadVariable("e").invoke("printStackTrace")) - ._(Stmt.throw_(RuntimeException.class, Refs.get("e"))) - .finish()) - .finish(); - } - - public static void createJavaReflectionConstructorInitializerUtilMethod( - final ClassStructureBuilder classBuilder) { - - if (classBuilder.getClassDefinition().getMethod(JAVA_REFL_CONSTRUCTOR_UTIL_METH, Class.class, - Class[].class) != null) { - return; - } - - classBuilder.privateMethod(Constructor.class, JAVA_REFL_CONSTRUCTOR_UTIL_METH).modifiers(Modifier.Static) - .parameters(DefParameters.of(Parameter.of(Class.class, "cls"), Parameter.of(Class[].class, "parms"))) - .body() - ._(Stmt.try_() - ._(Stmt.declareVariable("cons", Stmt.loadVariable("cls").invoke("getDeclaredConstructor", - Stmt.loadVariable("parms")))) - ._(Stmt.loadVariable("cons").invoke("setAccessible", true)) - ._(Stmt.loadVariable("cons").returnValue()) - .finish() - .catch_(Throwable.class, "e") - ._(Stmt.loadVariable("e").invoke("printStackTrace")) - ._(Stmt.throw_(RuntimeException.class, Refs.get("e"))) - .finish()) - .finish(); - } - - public static String initCachedField(final ClassStructureBuilder classBuilder, final MetaField f) { - createJavaReflectionFieldInitializerUtilMethod(classBuilder); - - final String fieldName = PrivateAccessUtil.getPrivateFieldAccessorName(f) + "_fld"; - - if (classBuilder.getClassDefinition().getField(fieldName) != null) { - return fieldName; - } - - classBuilder.privateField(fieldName, Field.class).modifiers(Modifier.Static) - .initializesWith(Stmt.invokeStatic(classBuilder.getClassDefinition(), JAVA_REFL_FLD_UTIL_METH, - f.getDeclaringClass(), f.getName())).finish(); - - return fieldName; - } - - public static String initCachedMethod(final ClassStructureBuilder classBuilder, final MetaMethod m) { - createJavaReflectionMethodInitializerUtilMethod(classBuilder); - - final String fieldName = PrivateAccessUtil.getPrivateMethodName(m) + "_meth"; - - classBuilder.privateField(fieldName, Method.class).modifiers(Modifier.Static) - .initializesWith(Stmt.invokeStatic(classBuilder.getClassDefinition(), JAVA_REFL_METH_UTIL_METH, - m.getDeclaringClass(), m.getName(), MetaClassFactory.asClassArray(m.getParameters()))).finish(); - - return fieldName; - } - - public static String initCachedMethod(final ClassStructureBuilder classBuilder, final MetaConstructor c) { - createJavaReflectionConstructorInitializerUtilMethod(classBuilder); - - final String fieldName = PrivateAccessUtil.getPrivateMethodName(c) + "_meth"; - - classBuilder.privateField(fieldName, Constructor.class).modifiers(Modifier.Static) - .initializesWith(Stmt.invokeStatic(classBuilder.getClassDefinition(), JAVA_REFL_CONSTRUCTOR_UTIL_METH, - c.getDeclaringClass(), MetaClassFactory.asClassArray(c.getParameters()))).finish(); - - return fieldName; - } - - - @Override - public void createWritableField(final MetaClass type, - final ClassStructureBuilder classBuilder, - final MetaField field, - final Modifier[] modifiers) { - - final String cachedField = initCachedField(classBuilder, field); - final String setterName = getReflectionFieldSetterName(field); - - final MethodCommentBuilder> methodBuilder = - classBuilder.privateMethod(void.class, PrivateAccessUtil.getPrivateFieldAccessorName(field)); - - if (!field.isStatic()) { - methodBuilder - .parameters( - DefParameters.fromParameters( - Parameter.of(field.getDeclaringClass().getErased(), "instance"), - Parameter.of(field.getType(), "value") - ) - ); - } - - methodBuilder.modifiers(modifiers) - .body() - ._(Stmt.try_() - ._(Stmt.loadVariable(cachedField).invoke(setterName, Refs.get("instance"), Refs.get("value"))) - .finish() - .catch_(Throwable.class, "e") - ._(Stmt.loadVariable("e").invoke("printStackTrace")) - ._(Stmt.throw_(RuntimeException.class, Refs.get("e"))) - .finish()) - .finish(); - } - - - @Override - public void createReadableField(final MetaClass type, - final ClassStructureBuilder classBuilder, - final MetaField field, - final Modifier[] modifiers) { - - final String cachedField = initCachedField(classBuilder, field); - final String getterName = getReflectionFieldGetterName(field); - - final MethodCommentBuilder> methodBuilder = - classBuilder.privateMethod(field.getType().getErased(), PrivateAccessUtil.getPrivateFieldAccessorName(field)); - - if (!field.isStatic()) { - methodBuilder.parameters( - DefParameters.fromParameters( - Parameter.of(field.getDeclaringClass().getErased(), "instance") - ) - ); - } - - methodBuilder.modifiers(modifiers) - .body() - ._(Stmt.try_() - ._(Stmt.nestedCall(Cast.to(field.getType().getErased(), Stmt.loadVariable(cachedField) - .invoke(getterName, field.isStatic() ? null : Refs.get("instance")))).returnValue()) - .finish() - .catch_(Throwable.class, "e") - ._(Stmt.loadVariable("e").invoke("printStackTrace")) - ._(Stmt.throw_(RuntimeException.class, Refs.get("e"))) - .finish()) - .finish(); - } - - @Override - public void makeMethodAccessible(final ClassStructureBuilder classBuilder, - final MetaMethod method, - final Modifier[] modifiers) { - - final List wrapperDefParms = new ArrayList(); - - if (!method.isStatic()) { - wrapperDefParms.add(Parameter.of(method.getDeclaringClass().getErased(), "instance")); - } - - final List methodDefParms = DefParameters.from(method).getParameters(); - wrapperDefParms.addAll(methodDefParms); - - final Object[] args = new Object[methodDefParms.size()]; - - int i = 0; - for (final Parameter p : methodDefParms) { - args[i++] = Refs.get(p.getName()); - } - - final String cachedMethod = initCachedMethod(classBuilder, method); - - final BlockBuilder body - = classBuilder.publicMethod(method.getReturnType(), - PrivateAccessUtil.getPrivateMethodName(method)) - .parameters(DefParameters.fromParameters(wrapperDefParms)) - .modifiers(modifiers) - .body(); - - final BlockBuilder tryBuilder = Stmt.try_(); - - final ContextualStatementBuilder statementBuilder = Stmt.loadVariable(cachedMethod) - .invoke("invoke", method.isStatic() ? null : Refs.get("instance"), args); - - if (method.getReturnType().isVoid()) { - tryBuilder._(statementBuilder); - } - else { - tryBuilder._(Stmt.castTo(method.getReturnType().asBoxed(), statementBuilder).returnValue()); - } - - body._(tryBuilder - .finish() - .catch_(Throwable.class, "e") - ._(Stmt.loadVariable("e").invoke("printStackTrace")) - ._(Stmt.throw_(RuntimeException.class, Refs.get("e"))) - .finish()) - .finish(); - } - - @Override - public void makeConstructorAccessible(final ClassStructureBuilder classBuilder, - final MetaConstructor constructor) { - - final DefParameters methodDefParms = DefParameters.from(constructor); - final String cachedMethod = initCachedMethod(classBuilder, constructor); - - final Object[] args = new Object[methodDefParms.getParameters().size()]; - - int i = 0; - for (final Parameter p : methodDefParms.getParameters()) { - args[i++] = Refs.get(p.getName()); - } - - final BlockBuilder body = classBuilder.publicMethod(constructor.getReturnType(), - PrivateAccessUtil.getPrivateMethodName(constructor)) - .parameters(methodDefParms) - .modifiers(Modifier.Static) - .body(); - - final Statement tryBuilder = - Stmt.try_() - .append( - Stmt.nestedCall( - Stmt.castTo(constructor.getReturnType(), - Stmt.loadVariable(cachedMethod).invoke("newInstance", - (Object) args))).returnValue()) - .finish() - .catch_(Throwable.class, "e") - .append(Stmt.loadVariable("e").invoke("printStackTrace")) - .append(Stmt.throw_(RuntimeException.class, Refs.get("e"))) - .finish(); - - body.append(tryBuilder).finish(); - } - - public static String getReflectionFieldGetterName(final MetaField f) { - final MetaClass t = f.getType(); - - if (!t.isPrimitive()) { - return "get"; - } - else if (t.getFullyQualifiedName().equals("int")) { - return "getInt"; - } - else if (t.getFullyQualifiedName().equals("short")) { - return "getShort"; - } - else if (t.getFullyQualifiedName().equals("boolean")) { - return "getBoolean"; - } - else if (t.getFullyQualifiedName().equals("double")) { - return "getDouble"; - } - else if (t.getFullyQualifiedName().equals("float")) { - return "getFloat"; - } - else if (t.getFullyQualifiedName().equals("byte")) { - return "getByte"; - } - else if (t.getFullyQualifiedName().equals("long")) { - return "getLong"; - } - else if (t.getFullyQualifiedName().equals("char")) { - return "getChar"; - } - return null; - } - - public static String getReflectionFieldSetterName(final MetaField f) { - final MetaClass t = f.getType(); - - if (!t.isPrimitive()) { - return "set"; - } - else if (t.getFullyQualifiedName().equals("int")) { - return "setInt"; - } - else if (t.getFullyQualifiedName().equals("short")) { - return "setShort"; - } - else if (t.getFullyQualifiedName().equals("boolean")) { - return "setBoolean"; - } - else if (t.getFullyQualifiedName().equals("double")) { - return "setDouble"; - } - else if (t.getFullyQualifiedName().equals("float")) { - return "setFloat"; - } - else if (t.getFullyQualifiedName().equals("byte")) { - return "setByte"; - } - else if (t.getFullyQualifiedName().equals("long")) { - return "setLong"; - } - else if (t.getFullyQualifiedName().equals("char")) { - return "setChar"; - } - return null; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/Refs.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/Refs.java deleted file mode 100644 index 322b9f7621c..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/Refs.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.util; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.VariableReference; -import org.jboss.errai.codegen.exception.OutOfScopeException; -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Mike Brock - */ -public abstract class Refs { - public static VariableReference get(final String name, final MetaClass type) { - return new VariableReference() { - @Override - public String getName() { - return name; - } - - @Override - public Statement getValue() { - return new Statement() { - @Override - public String generate(Context context) { - return name; - } - - @Override - public MetaClass getType() { - return type; - } - }; - } - }; - } - - public static VariableReference get(final String name) { - return new VariableReference() { - private MetaClass type; - - @Override - public String getName() { - return name; - } - - @Override - public Statement getValue() { - return new Statement() { - - String generatedCache; - - @Override - public String generate(final Context context) { - if (generatedCache != null) return generatedCache; - - final VariableReference var = context.getVariable(name); - - if (var == null) { - throw new OutOfScopeException("could not access variable: " + name); - } - - type = var.getType(); - - return generatedCache = name; - } - - @Override - public MetaClass getType() { - return type; - } - }; - } - - @Override - public String generate(final Context context) { - return getValue().generate(context); - } - - @Override - public MetaClass getType() { - return type; - } - - @Override - public String toString() { - return "[var-ref:" + name + "::" + type + "]"; - } - }; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/Stmt.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/Stmt.java deleted file mode 100644 index 4cf3d246505..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/Stmt.java +++ /dev/null @@ -1,322 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.util; - -import javax.enterprise.util.TypeLiteral; - -import org.jboss.errai.codegen.BooleanExpression; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.VariableReference; -import org.jboss.errai.codegen.builder.ArrayInitializationBuilder; -import org.jboss.errai.codegen.builder.BlockBuilder; -import org.jboss.errai.codegen.builder.CaseBlockBuilder; -import org.jboss.errai.codegen.builder.CatchBlockBuilder; -import org.jboss.errai.codegen.builder.ContextualStatementBuilder; -import org.jboss.errai.codegen.builder.ElseBlockBuilder; -import org.jboss.errai.codegen.builder.StatementBegin; -import org.jboss.errai.codegen.builder.StatementEnd; -import org.jboss.errai.codegen.builder.VariableDeclarationStart; -import org.jboss.errai.codegen.builder.VariableReferenceContextualStatementBuilder; -import org.jboss.errai.codegen.builder.WhileBuilder; -import org.jboss.errai.codegen.builder.impl.ObjectBuilder; -import org.jboss.errai.codegen.builder.impl.StatementBuilder; -import org.jboss.errai.codegen.meta.MetaClass; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public class Stmt { - - /** - * Create a new statement builder. - * @return a new statement builder instance. - */ - public static StatementBegin create() { - return StatementBuilder.create(); - } - - public static StatementBegin create(final Context ctx) { - return StatementBuilder.create(ctx); - } - - public static ArrayInitializationBuilder newArray(final MetaClass componentType) { - return StatementBuilder.create().newArray(componentType); - } - - public static ArrayInitializationBuilder newArray(final MetaClass componentType, - final Object... dimensions) { - return StatementBuilder.create().newArray(componentType, dimensions); - } - - public static ArrayInitializationBuilder newArray(final Class componentType) { - return StatementBuilder.create().newArray(componentType); - } - - public static ArrayInitializationBuilder newArray(final Class componentType, - final Object... dimensions) { - return StatementBuilder.create().newArray(componentType, dimensions); - } - - public static BlockBuilder do_() { - return StatementBuilder.create().do_(); - } - - public static BlockBuilder while_(final BooleanExpression condition) { - return StatementBuilder.create().while_(condition); - } - - public static BlockBuilder for_(final BooleanExpression condition) { - return StatementBuilder.create().for_(condition); - } - - public static BlockBuilder for_(final Statement initializer, - final BooleanExpression condition) { - return StatementBuilder.create().for_(initializer, condition); - } - - public static BlockBuilder for_(final Statement initializer, - final BooleanExpression condition, - final Statement countingExpression) { - return StatementBuilder.create().for_(initializer, condition, countingExpression); - } - - public static BlockBuilder if_(final BooleanExpression condition) { - return StatementBuilder.create().if_(condition); - } - - public static CaseBlockBuilder switch_(final Statement statement) { - return StatementBuilder.create().switch_(statement); - } - - public static BlockBuilder try_() { - return StatementBuilder.create().try_(); - } - - public static VariableDeclarationStart declareVariable(final Class type) { - return StatementBuilder.create().declareVariable(type); - } - - public static VariableDeclarationStart declareVariable(final MetaClass type) { - return StatementBuilder.create().declareVariable(type); - } - - public static StatementBuilder declareVariable(final VariableReference reference) { - return StatementBuilder.create().declareVariable(reference.getName(), reference.getType()); - } - - public static StatementBuilder declareVariable(final String name, - final Class type) { - return StatementBuilder.create().declareVariable(name, type); - } - - public static StatementBuilder declareVariable(final String name, - final TypeLiteral type) { - return StatementBuilder.create().declareVariable(name, type); - } - - public static StatementBuilder declareVariable(final String name, - final Object initialization) { - return StatementBuilder.create().declareVariable(name, initialization); - } - - public static StatementBuilder declareVariable(final VariableReference ref, - final Object initialization) { - return StatementBuilder.create().declareVariable(ref.getName(), ref.getType(), initialization); - } - - public static StatementBuilder declareVariable(final String name, - final Class type, - final Object initialization) { - return StatementBuilder.create().declareVariable(name, type, initialization); - } - - public static StatementBuilder declareVariable(final String name, - final MetaClass type, - final Object initialization) { - return StatementBuilder.create().declareVariable(name, type, initialization); - } - - - public static StatementBuilder declareVariable(final String name, - final TypeLiteral type, - final Object initialization) { - return StatementBuilder.create().declareVariable(name, type, initialization); - } - - - public static StatementBuilder declareFinalVariable(final String name, - final Class type) { - return StatementBuilder.create().declareFinalVariable(name, type); - } - - public static StatementBuilder declareFinalVariable(final String name, - final TypeLiteral type) { - return StatementBuilder.create().declareFinalVariable(name, type); - } - - public static StatementBuilder declareFinalVariable(final VariableReference ref, - final Object initialization) { - return StatementBuilder.create().declareFinalVariable(ref.getName(), ref.getType(), initialization); - } - - public static StatementBuilder declareFinalVariable(final String name, - final Class type, - final Object initialization) { - return StatementBuilder.create().declareFinalVariable(name, type, initialization); - } - - public static StatementBuilder declareFinalVariable(final String name, - final MetaClass type, - final Object initialization) { - return StatementBuilder.create().declareFinalVariable(name, type, initialization); - } - - public static StatementBuilder declareFinalVariable(final String name, - final TypeLiteral type, - final Object initialization) { - return StatementBuilder.create().declareFinalVariable(name, type, initialization); - } - - public static VariableReferenceContextualStatementBuilder loadVariable(final VariableReference reference) { - return loadVariable(reference.getName(), reference.getIndexes()); - } - - public static VariableReferenceContextualStatementBuilder loadVariable(final String name, - final Object... indexes) { - return StatementBuilder.create().loadVariable(name, indexes); - } - - public static VariableReferenceContextualStatementBuilder loadClassMember(final String name, - final Object... indexes) { - return StatementBuilder.create().loadClassMember(name, indexes); - } - - public static ContextualStatementBuilder loadLiteral(final Object o) { - return StatementBuilder.create().loadLiteral(o); - } - - public static ContextualStatementBuilder load(final Object o) { - return StatementBuilder.create().load(o); - } - - public static ContextualStatementBuilder loadClassReference(final Object o) { - return StatementBuilder.create().loadClassReference(o); - } - - public static ContextualStatementBuilder invokeStatic(final MetaClass clazz, - final String methodName, - final Object... parameters) { - return StatementBuilder.create().invokeStatic(clazz, methodName, parameters); - } - - public static ContextualStatementBuilder invokeStatic(final Class clazz, - final String methodName, - final Object... parameters) { - return StatementBuilder.create().invokeStatic(clazz, methodName, parameters); - } - - public static ContextualStatementBuilder loadStatic(final Class clazz, - final String fieldName) { - return StatementBuilder.create().loadStatic(clazz, fieldName); - } - - public static ContextualStatementBuilder loadStatic(final MetaClass clazz, - final String fieldName) { - return StatementBuilder.create().loadStatic(clazz, fieldName); - } - - public static ContextualStatementBuilder castTo(final Class clazz, - final Statement stmt) { - return StatementBuilder.create().castTo(clazz, stmt); - } - - public static ContextualStatementBuilder castTo(final MetaClass clazz, - final Statement stmt) { - return StatementBuilder.create().castTo(clazz, stmt); - } - - public static ContextualStatementBuilder nestedCall(final Statement statement) { - return StatementBuilder.create().nestedCall(statement); - } - - public static ObjectBuilder newObject(final Class type) { - return StatementBuilder.create().newObject(type); - } - - public static ObjectBuilder newObject(final MetaClass type) { - return StatementBuilder.create().newObject(type); - } - - public static ObjectBuilder newObject(final TypeLiteral type) { - return StatementBuilder.create().newObject(type); - } - - public static Statement newObject(final Class type, Object... parms) { - return StatementBuilder.create().newObject(type, parms); - } - - public static Statement newObject(final MetaClass type, Object... parms) { - return StatementBuilder.create().newObject(type, parms); - } - - public static Statement newObject(final TypeLiteral type, Object... parms) { - return StatementBuilder.create().newObject(type, parms); - } - - public static StatementEnd throw_(final Class throwableType, - final Object... parameters) { - return StatementBuilder.create().throw_(throwableType, parameters); - } - - public static StatementEnd throw_(final String exceptionVarName) { - return StatementBuilder.create().throw_(exceptionVarName); - } - - public static StatementEnd label(final String label) { - return StatementBuilder.create().label(label); - } - - public static StatementEnd break_() { - return StatementBuilder.create().break_(); - } - - public static StatementEnd break_(final String label) { - return StatementBuilder.create().break_(label); - } - - public static StatementEnd continue_() { - return StatementBuilder.create().continue_(); - } - - public static StatementEnd continue_(final String label) { - return StatementBuilder.create().continue_(label); - } - - public static StatementEnd returnVoid() { - return StatementBuilder.create().returnVoid(); - } - - public static Statement codeComment(final String comment) { - return StatementBuilder.create().codeComment(comment); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/Str.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/Str.java deleted file mode 100644 index 2953cc4afe8..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/main/java/org/jboss/errai/codegen/util/Str.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.util; - -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.StringExpression; -import org.jboss.errai.codegen.StringOperator; -import org.jboss.errai.codegen.builder.impl.StringExpressionBuilder; - -/** - * @author Slava Pankov - */ -public class Str { - - public static StringExpression expr(final Object lhs, final StringOperator operator, final Object rhs) { - return StringExpressionBuilder.create(lhs, operator, rhs); - } - - public static StringExpression expr(final StringOperator operator, final Object rhs) { - return StringExpressionBuilder.create(operator, rhs); - } - - public static StringExpression expr(final Statement lhs) { - return StringExpressionBuilder.create(lhs); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/AbstractCodegenTest.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/AbstractCodegenTest.java deleted file mode 100644 index 6035e980041..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/AbstractCodegenTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test; - -import org.jboss.errai.codegen.builder.impl.StatementBuilder; -import org.jboss.errai.codegen.util.GenUtil; -import org.junit.Before; - -/** - * Base class for all {@link StatementBuilder} tests. - * - * @author Christian Sadilek - */ -public abstract class AbstractCodegenTest { - - @Before - public void onBefore() { - GenUtil.setPermissiveMode(false); - } - - /** - * assertEquals, less sensitive to indentation differences. - * TODO compare parsed ASTs instead? - * - * @param expected - * @param actual - */ - protected static void assertEquals(String expected, String actual) { - org.junit.Assert.assertEquals(expected.replaceAll("\\s+", " ").trim(), - actual.replaceAll("\\s+", " ").trim()); - } - - protected static void assertEquals(String message, String expected, String actual) { - org.junit.Assert.assertEquals(message, expected == null ? null : expected.replaceAll("\\s+", " ").trim(), - actual == null ? null : actual.replaceAll("\\s+", " ").trim()); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/AllStatementBuilderTests.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/AllStatementBuilderTests.java deleted file mode 100644 index 05eac131213..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/AllStatementBuilderTests.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test; - -import org.jboss.errai.codegen.util.GenUtil; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -/** - * @author Christian Sadilek - */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ - AnnotationEncoderTest.class, - AnnotationTest.class, - AnonymousClassStructureBuilderTest.class, - ArithmeticTest.class, - ContextBuilderTest.class, - ClassBuilderTest.class, - IfBlockBuilderTest.class, - InvocationBuilderTest.class, - LiteralTest.class, - LoopBuilderTest.class, - ProxyMakerTest.class, - StatementBuilderTest.class, - SwitchBlockBuilderTest.class, - TryBlockBuilderTest.class}) -public class AllStatementBuilderTests { - static { - GenUtil.setPermissiveMode(false); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/AnnotationEncoderTest.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/AnnotationEncoderTest.java deleted file mode 100644 index 270679a8dd7..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/AnnotationEncoderTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test; - -import java.lang.annotation.Target; - -import javax.annotation.PostConstruct; - -import org.jboss.errai.codegen.AnnotationEncoder; -import org.jboss.errai.codegen.test.model.MyBean; -import org.jboss.errai.codegen.test.model.MyTestAnnotation; -import org.junit.Test; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public class AnnotationEncoderTest extends AbstractCodegenTest { - - @Test - public void testEncodeAnnotation() { - String enc = AnnotationEncoder.encode(PostConstruct.class.getAnnotation(Target.class)).generate(null); - - assertEquals("new java.lang.annotation.Target() { " + - "public Class annotationType() { " + - " return java.lang.annotation.Target.class; " + - "} " + - "public String toString() { " + - " return \"@java.lang.annotation.Target(value={METHOD})\"; " + - "} " + - "public java.lang.annotation.ElementType[] value() { " + - " return new java.lang.annotation.ElementType[] { " + - " java.lang.annotation.ElementType.METHOD }; " + - "} " + - "}", enc); - } - - @Test - public void testEncodeAnnotationWithMultipleProperties() { - String enc = AnnotationEncoder.encode(MyBean.class.getAnnotation(MyTestAnnotation.class)).generate(null); - - assertEquals("new org.jboss.errai.codegen.test.model.MyTestAnnotation() { " + - "public Class annotationType() { " + - " return org.jboss.errai.codegen.test.model.MyTestAnnotation.class; " + - "} " + - "public String foo() { " + - " return \"barfoo\"; " + - "} " + - "public org.jboss.errai.codegen.test.model.TEnum testEum() { " + - " return org.jboss.errai.codegen.test.model.TEnum.FOURTH; " + - "} " + - "public String toString() { " + - " return \"@org.jboss.errai.codegen.test.model.MyTestAnnotation(foo=\\\"barfoo\\\", testEum=FOURTH)\"; " + - "} " + - "}", enc); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/AnnotationTest.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/AnnotationTest.java deleted file mode 100644 index fc4de609f63..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/AnnotationTest.java +++ /dev/null @@ -1,633 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test; - -import java.lang.annotation.Annotation; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; -import java.util.List; -import java.util.Set; - -import org.jboss.errai.codegen.builder.ClassStructureBuilder; -import org.jboss.errai.codegen.builder.impl.ClassBuilder; -import org.junit.Test; - -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -/** - * Tests the generation of annotations. - * - * @author Johannes Barop - */ -public class AnnotationTest extends AbstractCodegenTest { - - @Test - public void testSingleBoolean() { - String expected = "" + - "import org.jboss.errai.codegen.test.AnnotationTest.BooleanAnnotation;\n" + - "@BooleanAnnotation(arrayValue = false, value = false)\n" + - "public class FooBar {}"; - String cls = constructTypeWithAnnotation(constructBooleanAnnotation(false)); - assertEquals(expected, cls); - } - - @Test - public void testMultiBoolean() { - String expected = "" + - "import org.jboss.errai.codegen.test.AnnotationTest.BooleanAnnotation;\n" + - "@BooleanAnnotation(arrayValue = {true, false, true}, value = true)\n" + - "public class FooBar {}"; - String cls = constructTypeWithAnnotation(constructBooleanAnnotation(true, false, true)); - assertEquals(expected, cls); - } - - @Test - public void testSingleByte() { - String expected = "" + - "import org.jboss.errai.codegen.test.AnnotationTest.ByteAnnotation;\n" + - "@ByteAnnotation(arrayValue = 1, value = 1)\n" + - "public class FooBar {}"; - String cls = constructTypeWithAnnotation(constructByteAnnotation(new byte[]{1})); - assertEquals(expected, cls); - } - - @Test - public void testMultiByte() { - String expected = "" + - "import org.jboss.errai.codegen.test.AnnotationTest.ByteAnnotation;\n" + - "@ByteAnnotation(arrayValue = {1, 2, 3}, value = 1)\n" + - "public class FooBar {}"; - String cls = constructTypeWithAnnotation(constructByteAnnotation(new byte[]{1, 2, 3})); - assertEquals(expected, cls); - } - - @Test - public void testSingleChar() { - String expected = "" + - "import org.jboss.errai.codegen.test.AnnotationTest.CharAnnotation;\n" + - "@CharAnnotation(arrayValue = 'a', value = 'a')\n" + - "public class FooBar {}"; - String cls = constructTypeWithAnnotation(constructCharAnnotation('a')); - assertEquals(expected, cls); - } - - @Test - public void testMultiChar() { - String expected = "" + - "import org.jboss.errai.codegen.test.AnnotationTest.CharAnnotation;\n" + - "@CharAnnotation(arrayValue = {'a', 'b', 'c'}, value = 'a')\n" + - "public class FooBar {}"; - String cls = constructTypeWithAnnotation(constructCharAnnotation('a', 'b', 'c')); - assertEquals(expected, cls); - } - - @Test - public void testSingleShort() { - String expected = "" + - "import org.jboss.errai.codegen.test.AnnotationTest.ShortAnnotation;\n" + - "@ShortAnnotation(arrayValue = 1, value = 1)\n" + - "public class FooBar {}"; - String cls = constructTypeWithAnnotation(constructShortAnnotation(new short[]{1})); - assertEquals(expected, cls); - } - - @Test - public void testMultiShort() { - String expected = "" + - "import org.jboss.errai.codegen.test.AnnotationTest.ShortAnnotation;\n" + - "@ShortAnnotation(arrayValue = {1, 2, 3}, value = 1)\n" + - "public class FooBar {}"; - String cls = constructTypeWithAnnotation(constructShortAnnotation(new short[]{1, 2, 3})); - assertEquals(expected, cls); - } - - @Test - public void testSingleInt() { - String expected = "" + - "import org.jboss.errai.codegen.test.AnnotationTest.IntAnnotation;\n" + - "@IntAnnotation(arrayValue = 1, value = 1)\n" + - "public class FooBar {}"; - String cls = constructTypeWithAnnotation(constructIntAnnotation(1)); - assertEquals(expected, cls); - } - - @Test - public void testMultiInt() { - String expected = "" + - "import org.jboss.errai.codegen.test.AnnotationTest.IntAnnotation;\n" + - "@IntAnnotation(arrayValue = {1, 2, 3}, value = 1)\n" + - "public class FooBar {}"; - String cls = constructTypeWithAnnotation(constructIntAnnotation(1, 2, 3)); - assertEquals(expected, cls); - } - - @Test - public void testSingleLong() { - String expected = "" + - "import org.jboss.errai.codegen.test.AnnotationTest.LongAnnotation;\n" + - "@LongAnnotation(arrayValue = 1L, value = 1L)\n" + - "public class FooBar {}"; - String cls = constructTypeWithAnnotation(constructLongAnnotation(1l)); - assertEquals(expected, cls); - } - - @Test - public void testMultiLong() { - String expected = "" + - "import org.jboss.errai.codegen.test.AnnotationTest.LongAnnotation;\n" + - "@LongAnnotation(arrayValue = {1L, 2L, 3L}, value = 1L)\n" + - "public class FooBar {}"; - String cls = constructTypeWithAnnotation(constructLongAnnotation(1l, 2l, 3l)); - assertEquals(expected, cls); - } - - @Test - public void testSingleFloat() { - String expected = "" + - "import org.jboss.errai.codegen.test.AnnotationTest.FloatAnnotation;\n" + - "@FloatAnnotation(arrayValue = 1.1f, value = 1.1f)\n" + - "public class FooBar {}"; - String cls = constructTypeWithAnnotation(constructFloatAnnotation(1.1f)); - assertEquals(expected, cls); - } - - @Test - public void testMultiFloat() { - String expected = "" + - "import org.jboss.errai.codegen.test.AnnotationTest.FloatAnnotation;\n" + - "@FloatAnnotation(arrayValue = {1.1f, 2.22f, 3.333f}, value = 1.1f)\n" + - "public class FooBar {}"; - String cls = constructTypeWithAnnotation(constructFloatAnnotation(1.1f, 2.22f, 3.333f)); - assertEquals(expected, cls); - } - - @Test - public void testSingleDouble() { - String expected = "" + - "import org.jboss.errai.codegen.test.AnnotationTest.DoubleAnnotation;\n" + - "@DoubleAnnotation(arrayValue = 1.1d, value = 1.1d)\n" + - "public class FooBar {}"; - String cls = constructTypeWithAnnotation(constructDoubleAnnotation(1.1)); - assertEquals(expected, cls); - } - - @Test - public void testMultiDouble() { - String expected = "" + - "import org.jboss.errai.codegen.test.AnnotationTest.DoubleAnnotation;\n" + - "@DoubleAnnotation(arrayValue = {1.1d, 2.22d, 3.333d}, value = 1.1d)\n" + - "public class FooBar {}"; - String cls = constructTypeWithAnnotation(constructDoubleAnnotation(1.1, 2.22, 3.333)); - assertEquals(expected, cls); - } - - @Test - public void testSingleString() { - String expected = "" + - "import org.jboss.errai.codegen.test.AnnotationTest.StringAnnotation;\n" + - "@StringAnnotation(arrayValue = \"Hello World\", value = \"Hello World\")\n" + - "public class FooBar {}"; - String cls = constructTypeWithAnnotation(constructStringAnnotation("Hello World")); - assertEquals(expected, cls); - } - - @Test - public void testMultiString() { - String expected = "" + - "import org.jboss.errai.codegen.test.AnnotationTest.StringAnnotation;\n" + - "@StringAnnotation(arrayValue = {\"Hang\", \"to\", \"your\", \"helmet\"}, value = \"Hang\")\n" + - "public class FooBar {}"; - String cls = constructTypeWithAnnotation(constructStringAnnotation("Hang", "to", "your", "helmet")); - assertEquals(expected, cls); - } - - @Test - public void testSingleClass() { - String expected = "" + - "import java.util.Set;\n" + - "import org.jboss.errai.codegen.test.AnnotationTest.ClassAnnotation;\n" + - "@ClassAnnotation(arrayValue = Set.class, value = Set.class)\n" + - "public class FooBar {}"; - String cls = constructTypeWithAnnotation(constructClassAnnotation(Set.class)); - assertEquals(expected, cls); - } - - @Test - public void testMultiClass() { - String expected = "" + - "import java.util.List;\n" + - "import java.util.Set;\n" + - "import org.jboss.errai.codegen.test.AnnotationTest.ClassAnnotation;\n" + - "@ClassAnnotation(arrayValue = {Set.class, List.class}, value = Set.class)\n" + - "public class FooBar {}"; - String cls = constructTypeWithAnnotation(constructClassAnnotation(Set.class, List.class)); - assertEquals(expected, cls); - } - - @Test - public void testSingleEnum() { - String expected = "" + - "import org.jboss.errai.codegen.test.AnnotationTest.EnumAnnotation;\n" + - "import org.jboss.errai.codegen.test.AnnotationTest.SimpleEnum;\n" + - "@EnumAnnotation(arrayValue = SimpleEnum.YES, value = SimpleEnum.YES)\n" + - "public class FooBar {}"; - String cls = constructTypeWithAnnotation(constructEnumAnnotation(SimpleEnum.YES)); - assertEquals(expected, cls); - } - - @Test - public void testMultiEnum() { - String expected = "" + - "import org.jboss.errai.codegen.test.AnnotationTest.EnumAnnotation;\n" + - "import org.jboss.errai.codegen.test.AnnotationTest.SimpleEnum;\n" + - "@EnumAnnotation(arrayValue = {SimpleEnum.YES, SimpleEnum.NO, SimpleEnum.YES}, value = SimpleEnum.YES)\n" + - "public class FooBar {}"; - String cls = constructTypeWithAnnotation(constructEnumAnnotation(SimpleEnum.YES, SimpleEnum.NO, SimpleEnum.YES)); - assertEquals(expected, cls); - } - - @Test - public void testSingleAnnotation() { - String expected = "" + - "import org.jboss.errai.codegen.test.AnnotationTest.AnnotationAnnotation;\n" + - "import org.jboss.errai.codegen.test.AnnotationTest.BooleanAnnotation;\n" + - "@AnnotationAnnotation(arrayValue = \n" + - " @BooleanAnnotation(arrayValue = {true, false}, value = true),\n" + - " value = @BooleanAnnotation(arrayValue = {true, false}, value = true))\n" + - "public class FooBar {}"; - String cls = constructTypeWithAnnotation(constructAnnotationAnnotation(constructBooleanAnnotation(true, false))); - assertEquals(expected, cls); - } - - @Test - public void testMultiAnnotation() { - // XXX: - // FIXME: The PrettyPrinter output in nested annotations is different - String expected = "" + - "import org.jboss.errai.codegen.test.AnnotationTest.AnnotationAnnotation;\n" + - "import org.jboss.errai.codegen.test.AnnotationTest.BooleanAnnotation;\n" + - "@AnnotationAnnotation(arrayValue = {\n" + - " @BooleanAnnotation(arrayValue = { true, false }, value = true),\n" + /* XXX */ - " @BooleanAnnotation(arrayValue = { true, true}, value = true)},\n" + /* XXX */ - " value = @BooleanAnnotation(arrayValue = {true, false}, value = true))\n" + - "public class FooBar {}"; - String cls = constructTypeWithAnnotation(constructAnnotationAnnotation(constructBooleanAnnotation(true, false), constructBooleanAnnotation(true, true))); - assertEquals(expected, cls); - } - - private static String constructTypeWithAnnotation(Annotation... annotations) { - ClassStructureBuilder builder = ClassBuilder.define("FooBar").publicScope().body(); - for (Annotation annotation : annotations) { - builder.getClassDefinition().addAnnotation(annotation); - } - return builder.toJavaString(); - } - - private enum SimpleEnum { - YES, NO - } - - @Target(TYPE) - @Retention(RUNTIME) - private @interface BooleanAnnotation { - boolean value(); - - boolean[] arrayValue(); - } - - private static BooleanAnnotation constructBooleanAnnotation(final boolean... values) { - return new BooleanAnnotation() { - @Override - public boolean value() { - return values[0]; - } - - @Override - public boolean[] arrayValue() { - return values; - } - - @Override - public Class annotationType() { - return BooleanAnnotation.class; - } - }; - } - - @Target(TYPE) - @Retention(RUNTIME) - private @interface ByteAnnotation { - byte value(); - - byte[] arrayValue(); - } - - private static ByteAnnotation constructByteAnnotation(final byte... values) { - return new ByteAnnotation() { - @Override - public byte value() { - return values[0]; - } - - @Override - public byte[] arrayValue() { - return values; - } - - @Override - public Class annotationType() { - return ByteAnnotation.class; - } - }; - } - - @Target(TYPE) - @Retention(RUNTIME) - private @interface CharAnnotation { - char value(); - - char[] arrayValue(); - } - - private static CharAnnotation constructCharAnnotation(final char... values) { - return new CharAnnotation() { - @Override - public char value() { - return values[0]; - } - - @Override - public char[] arrayValue() { - return values; - } - - @Override - public Class annotationType() { - return CharAnnotation.class; - } - }; - } - - @Target(TYPE) - @Retention(RUNTIME) - private @interface ShortAnnotation { - short value(); - - short[] arrayValue(); - } - - private static ShortAnnotation constructShortAnnotation(final short... values) { - return new ShortAnnotation() { - @Override - public short value() { - return values[0]; - } - - @Override - public short[] arrayValue() { - return values; - } - - @Override - public Class annotationType() { - return ShortAnnotation.class; - } - }; - } - - @Target(TYPE) - @Retention(RUNTIME) - private @interface IntAnnotation { - int value(); - - int[] arrayValue(); - } - - private static IntAnnotation constructIntAnnotation(final int... values) { - return new IntAnnotation() { - @Override - public int value() { - return values[0]; - } - - @Override - public int[] arrayValue() { - return values; - } - - @Override - public Class annotationType() { - return IntAnnotation.class; - } - }; - } - - @Target(TYPE) - @Retention(RUNTIME) - private @interface LongAnnotation { - long value(); - - long[] arrayValue(); - } - - private static LongAnnotation constructLongAnnotation(final long... values) { - return new LongAnnotation() { - @Override - public long value() { - return values[0]; - } - - @Override - public long[] arrayValue() { - return values; - } - - @Override - public Class annotationType() { - return LongAnnotation.class; - } - }; - } - - @Target(TYPE) - @Retention(RUNTIME) - private @interface FloatAnnotation { - float value(); - - float[] arrayValue(); - } - - private static FloatAnnotation constructFloatAnnotation(final float... values) { - return new FloatAnnotation() { - @Override - public float value() { - return values[0]; - } - - @Override - public float[] arrayValue() { - return values; - } - - @Override - public Class annotationType() { - return FloatAnnotation.class; - } - }; - } - - @Target(TYPE) - @Retention(RUNTIME) - private @interface DoubleAnnotation { - double value(); - - double[] arrayValue(); - } - - private static DoubleAnnotation constructDoubleAnnotation(final double... values) { - return new DoubleAnnotation() { - @Override - public double value() { - return values[0]; - } - - @Override - public double[] arrayValue() { - return values; - } - - @Override - public Class annotationType() { - return DoubleAnnotation.class; - } - }; - } - - @Target(TYPE) - @Retention(RUNTIME) - private @interface StringAnnotation { - String value(); - - String[] arrayValue(); - } - - private static StringAnnotation constructStringAnnotation(final String... values) { - return new StringAnnotation() { - @Override - public String value() { - return values[0]; - } - - @Override - public String[] arrayValue() { - return values; - } - - @Override - public Class annotationType() { - return StringAnnotation.class; - } - }; - } - - @Target(TYPE) - @Retention(RUNTIME) - private @interface ClassAnnotation { - Class value(); - - Class[] arrayValue(); - } - - private static ClassAnnotation constructClassAnnotation(final Class... values) { - return new ClassAnnotation() { - @Override - public Class value() { - return values[0]; - } - - @Override - public Class[] arrayValue() { - return values; - } - - @Override - public Class annotationType() { - return ClassAnnotation.class; - } - }; - } - - @Target(TYPE) - @Retention(RUNTIME) - private @interface EnumAnnotation { - SimpleEnum value(); - - SimpleEnum[] arrayValue(); - } - - private static EnumAnnotation constructEnumAnnotation(final SimpleEnum... values) { - return new EnumAnnotation() { - @Override - public SimpleEnum value() { - return values[0]; - } - - @Override - public SimpleEnum[] arrayValue() { - return values; - } - - @Override - public Class annotationType() { - return EnumAnnotation.class; - } - }; - } - - @Target(TYPE) - @Retention(RUNTIME) - private @interface AnnotationAnnotation { - BooleanAnnotation value(); - - BooleanAnnotation[] arrayValue(); - } - - private static AnnotationAnnotation constructAnnotationAnnotation(final BooleanAnnotation... values) { - return new AnnotationAnnotation() { - @Override - public BooleanAnnotation value() { - return values[0]; - } - - @Override - public BooleanAnnotation[] arrayValue() { - return values; - } - - @Override - public Class annotationType() { - return AnnotationAnnotation.class; - } - }; - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/AnonymousClassStructureBuilderTest.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/AnonymousClassStructureBuilderTest.java deleted file mode 100644 index ea77fcfeb5b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/AnonymousClassStructureBuilderTest.java +++ /dev/null @@ -1,228 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test; - -import java.lang.annotation.Retention; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Parameter; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.Variable; -import org.jboss.errai.codegen.builder.ClassStructureBuilder; -import org.jboss.errai.codegen.builder.impl.ClassBuilder; -import org.jboss.errai.codegen.builder.impl.ObjectBuilder; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.test.model.Bar; -import org.jboss.errai.codegen.test.model.Mrshlr; -import org.jboss.errai.codegen.util.Stmt; -import org.junit.Test; - -import static org.jboss.errai.codegen.meta.MetaClassFactory.parameterizedAs; -import static org.jboss.errai.codegen.meta.MetaClassFactory.typeParametersOf; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public class AnonymousClassStructureBuilderTest extends AbstractCodegenTest { - - @Test - public void testAnonymousAnnotation() { - - String src = ObjectBuilder.newInstanceOf(Retention.class) - .extend() - .publicOverridesMethod("annotationType") - .append(Stmt.load(Retention.class).returnValue()) - .finish() - .finish() - .toJavaString(); - - assertEquals("failed to generate anonymous annotation with overloaded method", - "new java.lang.annotation.Retention() {\n" + - "public Class annotationType() {\n" + - "return java.lang.annotation.Retention.class;\n" + - "}\n" + - "}", src); - } - - @Test - public void testAnonymousClass() { - - String src = ObjectBuilder.newInstanceOf(Bar.class, Context.create().autoImport()) - .extend() - .publicOverridesMethod("setName", Parameter.of(String.class, "name")) - .append(Stmt.loadClassMember("name").assignValue(Variable.get("name"))) - .finish() - .finish() - .toJavaString(); - - assertEquals("failed to generate anonymous class with overloaded construct", - "new Bar() {\n" + - "public void setName(String name) {\n" + - "this.name = name;\n" + - "}\n" + - "}", src); - } - - @Test - public void testAnonymousClassWithConstructor() { - String src = ObjectBuilder.newInstanceOf(Bar.class, Context.create().autoImport()) - .extend("test") - .publicOverridesMethod("setName", Parameter.of(String.class, "name")) - .append(Stmt.loadClassMember("name").assignValue(Variable.get("name"))) - .finish() - .finish() - .toJavaString(); - - assertEquals("failed to generate anonymous class with overloaded construct", - "new Bar(\"test\") {\n" + - "public void setName(String name) {\n" + - "this.name = name;\n" + - "}\n" + - "}", src); - } - - @Test - public void testAnonymousClassWithInitializationBlock() { - String src = ObjectBuilder.newInstanceOf(Bar.class, Context.create().autoImport()) - .extend() - .initialize() - .append(Stmt.loadClassMember("name").assignValue("init")) - .finish() - .publicOverridesMethod("setName", Parameter.of(String.class, "name")) - .append(Stmt.loadClassMember("name").assignValue(Variable.get("name"))) - .finish() - .finish() - .toJavaString(); - - assertEquals("failed to generate anonymous class with overloaded construct", - "new Bar() {\n" + - "{\n" + - "name = \"init\";" + - "\n}\n" + - "public void setName(String name) {\n" + - "this.name = name;\n" + - "}\n" + - "}", src); - } - - @Test - public void testAnonymousClassReferencingOuterClass() { - ClassStructureBuilder outer = ClassBuilder.define("org.foo.Outer").publicScope().body(); - - Statement anonInner = - ObjectBuilder.newInstanceOf(Bar.class, Context.create().autoImport()) - .extend() - .publicOverridesMethod("setName", Parameter.of(String.class, "name")) - .append( - Stmt.loadStatic(outer.getClassDefinition(), "this").loadField("outerName").assignValue( - Variable.get("name"))) - .append(Stmt.loadStatic(outer.getClassDefinition(), "this").invoke("setOuterName", Variable.get("name"))) - .finish() - .finish(); - - String cls = outer - .publicField("outerName", String.class) - .finish() - .publicMethod(void.class, "setOuterName", Parameter.of(String.class, "outerName")) - .append(Stmt.loadClassMember("outerName").assignValue(Variable.get("outerName"))) - .finish() - .publicMethod(void.class, "test") - .append(anonInner) - .finish() - .toJavaString(); - - assertEquals("failed to generate anonymous class accessing outer class", - "package org.foo;\n" + - "import org.jboss.errai.codegen.test.model.Bar;\n" + - - "public class Outer {\n" + - "public String outerName;\n" + - "public void setOuterName(String outerName) {\n" + - "this.outerName = outerName;\n" + - "}\n" + - - "public void test() {\n" + - "new Bar() {\n" + - "public void setName(String name) {\n" + - "Outer.this.outerName = name;\n" + - "Outer.this.setOuterName(name);\n" + - "}\n" + - "};\n" + - "}\n" + - "}\n", cls); - } - - @Test - public void testAssignmentOfAnonymousClass() { - Statement stmt = ObjectBuilder.newInstanceOf(Retention.class) - .extend() - .publicOverridesMethod("annotationType") - .append(Stmt.load(Retention.class).returnValue()) - .finish() - .finish(); - - Statement declaration = Stmt.declareVariable(java.lang.annotation.Annotation.class) - .named("foo").initializeWith(stmt); - - String cls = declaration.generate(Context.create()); - - assertEquals("java.lang.annotation.Annotation foo = new java.lang.annotation.Retention() {\n" + - " public Class annotationType() {\n" + - " return java.lang.annotation.Retention.class;\n" + - " }\n" + - "\n" + - "\n" + - "};", cls); - } - - /** Regression test for ERRAI-363. */ - @Test - public void testReferenceToAnonymousClassMember() throws Exception { - ClassStructureBuilder builder = ClassBuilder.define("com.foo.A").publicScope().body(); - builder.privateMethod(void.class, "method") - .append(ObjectBuilder.newInstanceOf(Runnable.class).extend() - .privateField("memberOfRunnable", Object.class).finish() - .publicOverridesMethod("run").append(Stmt.loadVariable("memberOfRunnable").invoke("hashCode")).finish() - .finish()) - .finish(); - String javaString = builder.toJavaString(); - assertEquals("package com.foo; public class A { private void method() { new Runnable() { private Object memberOfRunnable; public void run() { memberOfRunnable.hashCode(); } }; } }", javaString); - } - - @Test - public void testParameterizedImplementation() throws Exception { - final MetaClass mrshlrClass = parameterizedAs(Mrshlr.class, typeParametersOf(Bar.class)); - - final ObjectBuilder builder = Stmt.newObject(mrshlrClass).extend() - .publicOverridesMethod("get") - .finish() - .finish(); - - final String javaString = builder.toJavaString(); - - assertEquals("new org.jboss.errai.codegen.test.model.Mrshlr() {\n" + - " public Class get() {\n" + - "\n" + - " }\n" + - "}", javaString); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/ArithmeticTest.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/ArithmeticTest.java deleted file mode 100644 index 3e60ae47b5f..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/ArithmeticTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test; - -import org.jboss.errai.codegen.ArithmeticExpression; -import org.jboss.errai.codegen.ArithmeticOperator; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.util.Arith; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class ArithmeticTest { - - @Test - public void testWideningByteChar() throws Exception { - ArithmeticExpression expr = Arith.expr((byte) 1, ArithmeticOperator.Addition, (char) 3); - assertEquals(MetaClassFactory.get(int.class), expr.getType()); - } - - @Test - public void testWideningCharByte() throws Exception { - ArithmeticExpression expr = Arith.expr((char) 1, ArithmeticOperator.Addition, (byte) 3); - assertEquals(MetaClassFactory.get(int.class), expr.getType()); - } - - @Test - public void testWideningIntLong() throws Exception { - ArithmeticExpression expr = Arith.expr(1, ArithmeticOperator.Addition, (long) 3); - assertEquals(MetaClassFactory.get(long.class), expr.getType()); - } - - @Test - public void testWideningLongInt() throws Exception { - ArithmeticExpression expr = Arith.expr((long) 1, ArithmeticOperator.Addition, 3); - assertEquals(MetaClassFactory.get(long.class), expr.getType()); - } - - @Test - public void testDoubleDoubleMakesDouble() throws Exception { - ArithmeticExpression expr = Arith.expr(1.0, ArithmeticOperator.Addition, 3.0); - assertEquals(MetaClassFactory.get(double.class), expr.getType()); - } - - @Test - public void testCharCharMakesInt() throws Exception { - ArithmeticExpression expr = Arith.expr((char) 1, ArithmeticOperator.Addition, (char) 3); - assertEquals(MetaClassFactory.get(int.class), expr.getType()); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/ClassBuilderTest.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/ClassBuilderTest.java deleted file mode 100644 index 6b5dde8c77b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/ClassBuilderTest.java +++ /dev/null @@ -1,617 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test; - -import java.io.Serializable; -import java.lang.annotation.Annotation; -import java.util.Map; - -import org.jboss.errai.codegen.InnerClass; -import org.jboss.errai.codegen.Modifier; -import org.jboss.errai.codegen.Parameter; -import org.jboss.errai.codegen.Variable; -import org.jboss.errai.codegen.builder.ClassStructureBuilder; -import org.jboss.errai.codegen.builder.impl.ClassBuilder; -import org.jboss.errai.codegen.exception.UndefinedMethodException; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.test.model.Baz; -import org.jboss.errai.codegen.test.model.tree.Parent; -import org.jboss.errai.codegen.util.Stmt; -import org.junit.Test; - -import static org.jboss.errai.codegen.test.ClassBuilderTestResult.ABSTRACT_CLASS; -import static org.jboss.errai.codegen.test.ClassBuilderTestResult.ABSTRACT_CLASS_WITH_ABSTRACT_METHODS; -import static org.jboss.errai.codegen.test.ClassBuilderTestResult.ABSTRACT_CLASS_WITH_ABSTRACT_METHODS_2; -import static org.jboss.errai.codegen.test.ClassBuilderTestResult.CLASS_DECLARING_INNER_CLASS; -import static org.jboss.errai.codegen.test.ClassBuilderTestResult.CLASS_DEFINITION_BY_IMPLEMENTING_INTERFACE; -import static org.jboss.errai.codegen.test.ClassBuilderTestResult.CLASS_IMPLEMENTING_INTERFACE; -import static org.jboss.errai.codegen.test.ClassBuilderTestResult.CLASS_IMPLEMENTING_MULTIPLE_INTERFACES; -import static org.jboss.errai.codegen.test.ClassBuilderTestResult.CLASS_WITH_ACCESSOR_METHODS; -import static org.jboss.errai.codegen.test.ClassBuilderTestResult.CLASS_WITH_CLASS_COMMENT; -import static org.jboss.errai.codegen.test.ClassBuilderTestResult.CLASS_WITH_COLLIDING_IMPORTS_WITH_INNER_CLASS; -import static org.jboss.errai.codegen.test.ClassBuilderTestResult.CLASS_WITH_COLLIDING_IMPORTS_WITH_INNER_CLASS_FIRST; -import static org.jboss.errai.codegen.test.ClassBuilderTestResult.CLASS_WITH_COLLIDING_IMPORTS_WITH_JAVA_LANG; -import static org.jboss.errai.codegen.test.ClassBuilderTestResult.CLASS_WITH_COLLIDING_IMPORTS_WITH_JAVA_LANG_FIRST; -import static org.jboss.errai.codegen.test.ClassBuilderTestResult.CLASS_WITH_CONSTRUCTORS_OF_ALL_SCOPES; -import static org.jboss.errai.codegen.test.ClassBuilderTestResult.CLASS_WITH_CONSTRUCTOR_CALLING_SUPER; -import static org.jboss.errai.codegen.test.ClassBuilderTestResult.CLASS_WITH_CONSTRUCTOR_CALLING_THIS; -import static org.jboss.errai.codegen.test.ClassBuilderTestResult.CLASS_WITH_FIELDS_OF_ALL_SCOPES; -import static org.jboss.errai.codegen.test.ClassBuilderTestResult.CLASS_WITH_FIELD_INHERITANCE; -import static org.jboss.errai.codegen.test.ClassBuilderTestResult.CLASS_WITH_JSNI_METHOD; -import static org.jboss.errai.codegen.test.ClassBuilderTestResult.CLASS_WITH_METHODS_OF_ALL_SCOPES; -import static org.jboss.errai.codegen.test.ClassBuilderTestResult.CLASS_WITH_METHOD_CALLING_METHOD_ON_SUPER; -import static org.jboss.errai.codegen.test.ClassBuilderTestResult.CLASS_WITH_METHOD_CALLING_METHOD_ON_THIS; -import static org.jboss.errai.codegen.test.ClassBuilderTestResult.CLASS_WITH_METHOD_HAVING_THROWS_DECLARATION; -import static org.jboss.errai.codegen.test.ClassBuilderTestResult.CLASS_WITH_METHOD_USING_INNER_CLASS; -import static org.jboss.errai.codegen.test.ClassBuilderTestResult.CLASS_WITH_PARENT; -import static org.jboss.errai.codegen.test.ClassBuilderTestResult.CLASS_WITH_STATIC_METHOD; -import static org.junit.Assert.fail; - -/** - * Tests the {@link ClassBuilder} API. - * - * @author Mike Brock - * @author Christian Sadilek - */ -public class ClassBuilderTest extends AbstractCodegenTest { - - @Test - public void testDefineClassImplementingInterface() { - final String cls = ClassBuilder.define("org.foo.Bar") - .publicScope() - .implementsInterface(Serializable.class) - .body() - .privateField("name", String.class) - .finish() - .toJavaString(); - System.out.println(cls); - - assertEquals("failed to generate class definition implementing an interface", CLASS_IMPLEMENTING_INTERFACE, cls); - } - - @Test - public void testDefineClassImplementingMultipleInterfaces() { - final String cls = ClassBuilder.define("org.foo.Bar") - .publicScope() - .implementsInterface(Serializable.class) - .implementsInterface(Cloneable.class) - .body() - .privateField("name", String.class) - .finish() - .toJavaString(); - - assertEquals("failed to generate class definition implementing multiple interfaces", - CLASS_IMPLEMENTING_MULTIPLE_INTERFACES, cls); - } - - @Test - public void testDefineClassWithInnerClass() { - final ClassStructureBuilder innerClass = ClassBuilder.define("Inner") - .publicScope().body(); - - final String cls = ClassBuilder.define("foo.bar.Baz") - .publicScope() - .body() - .declaresInnerClass(new InnerClass(innerClass.getClassDefinition())) - .toJavaString(); - - assertEquals("failed to generate class with method using inner class", - CLASS_DECLARING_INNER_CLASS, cls); - } - - @Test - public void testDefineInnerClassInMethod() { - final ClassStructureBuilder innerClass = ClassBuilder.define("Inner") - .packageScope() - .implementsInterface(Serializable.class) - .body() - .privateField("name", String.class) - .finish() - .publicMethod(void.class, "setName", Parameter.of(String.class, "name", true)) - .append(Stmt.loadClassMember("name").assignValue(Variable.get("name"))) - .finish(); - - final String cls = ClassBuilder.define("foo.bar.Baz") - .publicScope() - .body() - .publicMethod(void.class, "someMethod") - .append(new InnerClass(innerClass.getClassDefinition())) - .append(Stmt.newObject(innerClass.getClassDefinition())) - .finish() - .toJavaString(); - - assertEquals("failed to generate class with method using inner class", - CLASS_WITH_METHOD_USING_INNER_CLASS, cls); - } - - @Test - public void testDefineClassWithAccessorMethods() { - final String cls = ClassBuilder.define("org.foo.Foo") - .publicScope() - .body() - .privateField("name", String.class) - .initializesWith(Stmt.load("default")) - .finish() - .publicMethod(String.class, "getName") - .append(Stmt.loadVariable("name").returnValue()) - .finish() - .publicMethod(void.class, "setName", Parameter.of(String.class, "name")) - .append(Stmt.loadClassMember("name").assignValue(Variable.get("name"))) - .finish() - .toJavaString(); - - assertEquals("failed to generate class definition with accessor methods", CLASS_WITH_ACCESSOR_METHODS, cls); - } - - @Test - public void testDefineClassWithAccessorMethodsUsingThisKeyword() { - final String cls = ClassBuilder - .define("org.foo.Foo") - .publicScope() - .body() - .privateField("name", String.class) - .initializesWith(Stmt.load("default")) - .finish() - .publicMethod(String.class, "getName") - .append(Stmt.loadVariable("name").returnValue()) - .finish() - .publicMethod(void.class, "setName", Parameter.of(String.class, "name")) - .append(Stmt.loadVariable("this.name").assignValue(Variable.get("name"))) - .finish() - .toJavaString(); - - assertEquals("failed to generate class definition with accessor methods", CLASS_WITH_ACCESSOR_METHODS, cls); - } - - @Test - public void testDefineClassWithParent() { - final String cls = ClassBuilder - .define("org.foo.Foo", String.class) - .publicScope() - .body() - .publicConstructor(Parameter.of(int.class, "i")) - .finish() - .toJavaString(); - - assertEquals("failed to generate class with parent", CLASS_WITH_PARENT, cls); - } - - @Test - public void testDefineClassWithFieldInheritance() { - final String cls = ClassBuilder - .define("org.foo.Foo", Parent.class) - .publicScope() - .body() - .publicConstructor() - .append(Stmt.loadVariable("parentProtected").assignValue(0)) - .append(Stmt.loadVariable("parentPublic").assignValue(0)) - .finish() - .toJavaString(); - - assertEquals("failed to generate class with parent", CLASS_WITH_FIELD_INHERITANCE, cls); - } - - @Test - public void testDefineAbstractClass() { - - final String cls = ClassBuilder - .define("org.foo.Foo") - .publicScope() - .abstractClass() - .body() - .publicConstructor() - .finish() - .toJavaString(); - - assertEquals("failed to generate abstract class", ABSTRACT_CLASS, cls); - } - - @Test - public void testDefineAbstractClassWithAbstractMethods() { - - final String cls = ClassBuilder - .define("org.foo.Foo") - .publicScope() - .abstractClass() - .body() - .publicConstructor() - .finish() - .publicAbstractMethod(void.class, "foo") - .finish() - .protectedAbstractMethod(void.class, "bar") - .finish() - .publicMethod(void.class, "baz") - .finish() - .toJavaString(); - - assertEquals("failed to generate abstract class with abstract method", ABSTRACT_CLASS_WITH_ABSTRACT_METHODS, cls); - } - - @SuppressWarnings("unchecked") - @Test - public void testDefineAbstractClassWithAbstractMethods2() { - - final String cls = ClassBuilder - .define("org.foo.Foo") - .publicScope() - .abstractClass() - .body() - .publicConstructor() - .finish() - .publicAbstractMethod(MetaClassFactory.get(String.class), "someString").finish() - .publicAbstractMethod(Integer.class, "someInteger", Parameter.finalOf(long.class, "aLong")).finish() - .publicAbstractMethod(void.class, "foo", String.class, Integer.class).throws_(Throwable.class) - .protectedAbstractMethod(void.class, "bar", Long.class, Double.class).throws_(UnsupportedOperationException.class) - .protectedAbstractMethod(Long.class, "funTimes", Parameter.finalOf(String.class, "str")).finish() - .packageAbstractMethod(void.class, "foobaz", Map.class) .throws_(MetaClassFactory.get(ClassNotFoundException.class)) - .packageAbstractMethod(Float.class, "boringTimes", Parameter.of(byte[].class, "byteArr")).finish() - .publicMethod(void.class, "baz") - .finish() - .toJavaString(); - - assertEquals(ABSTRACT_CLASS_WITH_ABSTRACT_METHODS_2, cls); - } - - @Test - public void testDefineClassWithConstructorCallingSuper() { - final String cls = ClassBuilder.define("org.foo.Foo") - .publicScope() - .body() - .publicConstructor() - .callSuper() - .finish() - .toJavaString(); - - assertEquals("failed to generate class with constructor calling super()", - CLASS_WITH_CONSTRUCTOR_CALLING_SUPER, cls); - } - - @Test - public void testDefineClassWithConstructorCallingThis() { - final String cls = ClassBuilder.define("org.foo.Foo") - .publicScope() - .body() - .privateField("b", boolean.class) - .finish() - .publicConstructor() - .callThis(false) - .finish() - .publicConstructor(Parameter.of(boolean.class, "b")) - .append(Stmt.loadClassMember("b").assignValue(Variable.get("b"))) - .finish() - .toJavaString(); - - assertEquals("failed to generate class with constructor calling this()", - CLASS_WITH_CONSTRUCTOR_CALLING_THIS, cls); - } - - @Test - public void testDefineClassWithMethodCallingMethodOnThis() { - final String cls = ClassBuilder.define("org.foo.Foo") - .publicScope() - .body() - .publicMethod(void.class, "bar") - .append(Stmt.loadVariable("this").invoke("foo")) - .finish() - .publicMethod(String.class, "foo") - .append(Stmt.load(null).returnValue()) - .finish() - .toJavaString(); - - assertEquals("failed to generate class with method calling method on this", - CLASS_WITH_METHOD_CALLING_METHOD_ON_THIS, cls); - } - - @Test - public void testDefineClassWithMethodCallingInvalidMethodOnThis() { - try { - ClassBuilder.define("org.foo.Foo") - .publicScope() - .body() - .publicMethod(void.class, "bar") - .append(Stmt.loadVariable("this").invoke("foo", "invalidParam")) - .finish() - .publicMethod(String.class, "foo") - .append(Stmt.load(null).returnValue()) - .finish() - .toJavaString(); - fail("exprected UndefinedMethodException"); - } - catch (UndefinedMethodException udme) { - // expected - assertEquals("Wrong exception thrown", udme.getMethodName(), "foo"); - } - } - - @Test - public void testDefineClassWithMethodCallingMethodOnSuper() { - final String cls = ClassBuilder.define("org.foo.Foo") - .publicScope() - .body() - .publicMethod(void.class, "bar") - .append(Stmt.loadVariable("this").invoke("foo")) - .finish() - .publicMethod(String.class, "foo") - .append(Stmt.loadVariable("super").invoke("toString").returnValue()) - .finish() - .toJavaString(); - - assertEquals("failed to generate class with method calling method on this", - CLASS_WITH_METHOD_CALLING_METHOD_ON_SUPER, cls); - } - - @Test - public void testDefineClassWithMethodCallingInvalidMethodOnSuper() { - try { - ClassBuilder.define("org.foo.Foo") - .publicScope() - .body() - .publicMethod(void.class, "bar") - .append(Stmt.loadVariable("this").invoke("foo")) - .finish() - .publicMethod(String.class, "foo") - .append(Stmt.loadVariable("super").invoke("undefinedMethod")) - .finish() - .toJavaString(); - fail("exprected UndefinedMethodException"); - } - catch (UndefinedMethodException udme) { - // expected - assertEquals("Wrong exception thrown", udme.getMethodName(), "undefinedMethod"); - } - } - - @Test - public void testDefineClassWithMethodHavingThrowsDeclaration() { - @SuppressWarnings("unchecked") - final String cls = ClassBuilder - .define("org.foo.Foo") - .publicScope() - .body() - .publicMethod(void.class, "initialize") - .throws_(Exception.class, IllegalArgumentException.class) - .finish() - .toJavaString(); - - assertEquals("failed to generate class with method having throws declaration", - CLASS_WITH_METHOD_HAVING_THROWS_DECLARATION, cls); - } - - @Test - public void testDefineClassWithMethodsOfAllScopes() { - final String cls = ClassBuilder - .define("org.foo.Foo") - .publicScope() - .body() - .publicMethod(void.class, "publicMethod") - .finish() - .protectedMethod(void.class, "protectedMethod") - .finish() - .packageMethod(void.class, "packagePrivateMethod") - .finish() - .privateMethod(void.class, "privateMethod") - .finish() - .toJavaString(); - - assertEquals("failed to generate class with methods of all scopes", CLASS_WITH_METHODS_OF_ALL_SCOPES, cls); - } - - @Test - public void testDefineClassWithFieldsOfAllScopes() { - final String cls = ClassBuilder - .define("org.foo.Foo") - .publicScope() - .body() - .publicField("publicField", int.class) - .finish() - .protectedField("protectedField", int.class) - .finish() - .packageField("packagePrivateField", int.class) - .finish() - .privateField("privateField", int.class) - .finish() - .toJavaString(); - - assertEquals("failed to generate class with fields of all scopes", CLASS_WITH_FIELDS_OF_ALL_SCOPES, cls); - } - - @Test - public void testDefineClassWithConstructorsOfAllScopes() { - final String cls = ClassBuilder - .define("org.foo.Foo") - .publicScope() - .body() - .publicConstructor() - .finish() - .protectedConstructor() - .finish() - .packageConstructor() - .finish() - .privateConstructor() - .finish() - .toJavaString(); - - assertEquals("failed to generate class with constructors of all scopes", - CLASS_WITH_CONSTRUCTORS_OF_ALL_SCOPES, cls); - } - - @Test - public void testDefineClassByImplementingInterface() { - final String cls = ClassBuilder.implement(Baz.class) - .publicMethod(void.class, "someMethod") - .finish().toJavaString(); - - assertEquals("failed to generate class by implementing an interface", - CLASS_DEFINITION_BY_IMPLEMENTING_INTERFACE, cls); - } - - @Test - public void testDefineClassWithStaticMethod() { - final String cls = ClassBuilder.define("my.test.Clazz") - .publicScope().body() - .publicMethod(void.class, "test").modifiers(Modifier.Static) - .body() - .append(Stmt.loadStatic(System.class, "out").invoke("println", "Hello, World!")) - .finish() - .toJavaString(); - - assertEquals("failed to generate class with static method", CLASS_WITH_STATIC_METHOD, cls); - } - - @Test - public void testDefineClassWithJSNIMethod() { - final String cls = ClassBuilder.define("my.test.Clazz") - .publicScope().body() - .publicMethod(void.class, "test").modifiers(Modifier.JSNI) - .body() - .append(Stmt.loadStatic(System.class, "out").invoke("println", "Hello, World!")) - .finish() - .toJavaString(); - - assertEquals("failed to generate class with JSNI method", CLASS_WITH_JSNI_METHOD, cls); - } - - public interface TestInterface { - - } - - @Test - public void testCollidingImportsWithInnerClass() { - final String cls = ClassBuilder.define("my.test.Clazz") - .publicScope() - .implementsInterface(org.jboss.errai.codegen.test.model.TestInterface.class) - .implementsInterface(TestInterface.class) - .implementsInterface(Serializable.class) - .body() - .privateField("name", String.class) - .finish() - .toJavaString(); - - assertEquals("failed to generate class with colliding imports", - CLASS_WITH_COLLIDING_IMPORTS_WITH_INNER_CLASS, cls); - } - - @Test - public void testCollidingImportsWithInnerClassFirst() { - final String cls = ClassBuilder.define("my.test.Clazz") - .publicScope() - .implementsInterface(TestInterface.class) - .implementsInterface(org.jboss.errai.codegen.test.model.TestInterface.class) - .implementsInterface(Serializable.class) - .body() - .privateField("name", String.class) - .finish() - .toJavaString(); - - assertEquals("failed to generate class with colliding imports", - CLASS_WITH_COLLIDING_IMPORTS_WITH_INNER_CLASS_FIRST, cls); - } - - @Test - public void testCollidingImportsWithJavaLang() { - final String cls = ClassBuilder.define("my.test.Clazz") - .publicScope() - .body() - .privateField("i", org.jboss.errai.codegen.test.model.Integer.class) - .finish() - .privateField("j", Integer.class) - .finish() - .toJavaString(); - - assertEquals("failed to generate class with colliding imports", - CLASS_WITH_COLLIDING_IMPORTS_WITH_JAVA_LANG, cls); - } - - @Test - public void testCollidingImportsWithJavaLangFirst() { - final String cls = ClassBuilder.define("my.test.Clazz") - .publicScope() - .body() - .privateField("i", Integer.class) - .finish() - .privateField("j", org.jboss.errai.codegen.test.model.Integer.class) - .finish() - .toJavaString(); - - assertEquals("failed to generate class with colliding imports", - CLASS_WITH_COLLIDING_IMPORTS_WITH_JAVA_LANG_FIRST, cls); - } - - @Test - public void testThisReferenceWithStmtLoadVariable() { - final ClassStructureBuilder> body = - ClassBuilder.define("org.foo.Foo").publicScope().body(); - - final String cls = body - .publicMethod(body.getClassDefinition(), "getThis") - .append(Stmt.loadVariable("this").returnValue()) - .finish() - .toJavaString(); - - assertEquals("did not properly render 'this' reference", "package org.foo;\n" + - "\n" + - "\n" + - "public class Foo {\n" + - " public Foo getThis() {\n" + - " return this;\n" + - " }\n" + - "}", cls); - } - - @Test - public void testMethodAnnotated() { - - final String cls = ClassBuilder.define("MyRunnable") - .publicScope().implementsInterface(Runnable.class) - .body() - .publicMethod(void.class, "run") - .annotatedWith(new SuppressWarnings() { - @Override - public String[] value() { - return new String[]{"blah"}; - } - - @Override - public Class annotationType() { - return SuppressWarnings.class; - } - }).body() - .append(Stmt.returnVoid()) - .finish().toJavaString(); - - assertEquals("public class MyRunnable implements Runnable {\n" + - " @SuppressWarnings(\"blah\") public void run() {\n" + - " return;\n" + - " }\n" + - "}", cls); - } - - @Test - public void testClassComment() throws Exception { - final String cls = ClassBuilder.define("org.foo.Bar") - .classComment("A foo-ish bar") - .publicScope() - .body() - .toJavaString(); - - assertEquals(CLASS_WITH_CLASS_COMMENT, cls); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/ClassBuilderTestResult.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/ClassBuilderTestResult.java deleted file mode 100644 index d3f11bb528c..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/ClassBuilderTestResult.java +++ /dev/null @@ -1,307 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test; - -/** - * @author Christian Sadilek - */ -public interface ClassBuilderTestResult { - - public static final String CLASS_IMPLEMENTING_INTERFACE = - " package org.foo;" + - "\n" + - " import java.io.Serializable;\n" + - "\n" + - " public class Bar implements Serializable {\n" + - " private String name;\n" + - " }"; - - public static final String CLASS_IMPLEMENTING_MULTIPLE_INTERFACES = - " package org.foo;\n" + - " import java.io.Serializable;\n" + - "\n" + - " public class Bar implements Serializable, Cloneable {\n" + - " private String name;\n" + - " }"; - - public static final String CLASS_DECLARING_INNER_CLASS = - " package foo.bar;" + - "\n" + - " public class Baz {\n" + - " public class Inner {\n" + - " }" + - " }"; - - public static final String CLASS_WITH_METHOD_USING_INNER_CLASS = - " package foo.bar;" + - "\n" + - " import java.io.Serializable;\n" + - "\n" + - " public class Baz {\n" + - " public void someMethod() {\n" + - " class Inner implements Serializable {\n" + - " private String name;" + - " public void setName(final String name) {\n" + - " this.name = name;\n" + - " }\n" + - " }" + - " new Inner();" + - " }" + - " }"; - - public static final String CLASS_WITH_ACCESSOR_METHODS = - " package org.foo;\n" + - "\n" + - " public class Foo {\n" + - " private String name = \"default\";\n" + - " public String getName() {\n" + - " return name;\n" + - " }\n" + - " public void setName(String name) {\n" + - " this.name = name;\n" + - " }\n" + - " }"; - - public static final String CLASS_WITH_PARENT = - " package org.foo;\n" + - "\n" + - " public class Foo extends String {\n" + - " public Foo(int i) {" + - " }" + - " }"; - - public static final String CLASS_WITH_FIELD_INHERITANCE = - " package org.foo;" + - "" + - " import org.jboss.errai.codegen.test.model.tree.Parent;" + - "" + - " public class Foo extends Parent {" + - " public Foo() {" + - " parentProtected = 0;" + - " parentPublic = 0;" + - " }" + - " }"; - - public static final String ABSTRACT_CLASS = - " package org.foo;\n" + - "\n" + - " public abstract class Foo {\n" + - " public Foo() {" + - " }" + - " }"; - - public static final String ABSTRACT_CLASS_WITH_ABSTRACT_METHODS = - " package org.foo;\n" + - "\n" + - " public abstract class Foo {\n" + - " public Foo() {" + - " }" + - " public abstract void foo();" + - " protected abstract void bar();" + - " public void baz() {" + - " }" + - " }"; - - public static final String ABSTRACT_CLASS_WITH_ABSTRACT_METHODS_2 = - "package org.foo;\n" + - "\n" + - "import java.util.Map;\n" + - "\n" + - "public abstract class Foo {\n" + - " public Foo() {\n" + - "\n" + - " }\n" + - "\n" + - " public abstract String someString();\n" + - " public abstract Integer someInteger(final long aLong);\n" + - " public abstract void foo(String a0, Integer a1) throws Throwable;\n" + - " protected abstract void bar(Long a0, Double a1) throws UnsupportedOperationException;\n" + - " protected abstract Long funTimes(final String str);\n" + - " abstract void foobaz(Map a0) throws ClassNotFoundException;\n" + - " abstract Float boringTimes(byte[] byteArr);\n" + - " public void baz() {\n" + - "\n" + - " }\n" + - "}"; - - public static final String CLASS_WITH_CONSTRUCTOR_CALLING_SUPER = - " package org.foo;\n" + - "\n" + - " public class Foo {\n" + - " public Foo() {" + - " super();" + - " }" + - " }"; - - public static final String CLASS_WITH_CONSTRUCTOR_CALLING_THIS = - " package org.foo;\n" + - "\n" + - " public class Foo {\n" + - " private boolean b;" + - " public Foo() {" + - " this(false);" + - " }" + - " public Foo(boolean b) {" + - " this.b = b;" + - " }" + - " }"; - - public static final String CLASS_WITH_METHOD_CALLING_METHOD_ON_THIS = - " package org.foo;\n" + - "\n" + - " public class Foo {\n" + - " public void bar() {" + - " foo();" + - " }" + - " public String foo() {" + - " return null;" + - " }" + - " }"; - - public static final String CLASS_WITH_METHOD_CALLING_METHOD_ON_SUPER = - " package org.foo;\n" + - "\n" + - " public class Foo {\n" + - " public void bar() {" + - " foo();" + - " }" + - " public String foo() {" + - " return super.toString();" + - " }" + - " }"; - - public static final String CLASS_WITH_METHOD_HAVING_THROWS_DECLARATION = - " package org.foo;\n" + - "\n" + - " public class Foo {\n" + - " public void initialize() throws Exception, IllegalArgumentException {" + - " }" + - " }"; - - public static final String CLASS_WITH_METHODS_OF_ALL_SCOPES = - " package org.foo;\n" + - "\n" + - " public class Foo {\n" + - " public void publicMethod() {" + - " }" + - " protected void protectedMethod() {" + - " }" + - " void packagePrivateMethod() {" + - " }" + - " private void privateMethod() {" + - " }" + - " }"; - - public static final String CLASS_WITH_FIELDS_OF_ALL_SCOPES = - " package org.foo;\n" + - "\n" + - " public class Foo {\n" + - " public int publicField;\n" + - " protected int protectedField;\n" + - " int packagePrivateField;\n" + - " private int privateField;\n" + - " }"; - - public static final String CLASS_WITH_CONSTRUCTORS_OF_ALL_SCOPES = - " package org.foo;\n" + - "\n" + - " public class Foo {\n" + - " public Foo() {" + - " }" + - " protected Foo() {" + - " }" + - " Foo() {" + - " }" + - " private Foo() {" + - " }" + - " }"; - - public static final String CLASS_WITH_STATIC_METHOD = - " package my.test;\n" + - "\n" + - " public class Clazz {\n" + - " public static void test() {\n" + - " System.out.println(\"Hello, World!\");\n" + - " }\n" + - " }"; - - public static final String CLASS_WITH_JSNI_METHOD = - " package my.test;\n" + - "\n" + - " public class Clazz {\n" + - " public native void test() /*-{\n" + - " System.out.println(\"Hello, World!\");\n" + - " }-*/;\n" + - " }"; - - public static final String CLASS_DEFINITION_BY_IMPLEMENTING_INTERFACE = - " package org.jboss.errai.codegen.test.model;\n" + - "\n" + - " public class BazImpl implements Baz {\n" + - " public void someMethod() {\n" + - " }\n" + - " }"; - - public static final String CLASS_WITH_COLLIDING_IMPORTS_WITH_INNER_CLASS = - " package my.test;" + - "\n" + - " import java.io.Serializable;\n" + - " import org.jboss.errai.codegen.test.model.TestInterface;\n" + - "\n" + - " public class Clazz implements TestInterface, " + - " org.jboss.errai.codegen.test.ClassBuilderTest.TestInterface, Serializable {\n" + - " private String name;\n" + - " }"; - - public static final String CLASS_WITH_COLLIDING_IMPORTS_WITH_INNER_CLASS_FIRST = - " package my.test;" + - "\n" + - " import java.io.Serializable;\n" + - " import org.jboss.errai.codegen.test.ClassBuilderTest.TestInterface;\n" + - "\n" + - " public class Clazz implements TestInterface, " + - " org.jboss.errai.codegen.test.model.TestInterface, Serializable {\n" + - " private String name;\n" + - " }"; - - public static final String CLASS_WITH_COLLIDING_IMPORTS_WITH_JAVA_LANG = - " package my.test;" + - " import org.jboss.errai.codegen.test.model.Integer;\n" + - "\n" + - " public class Clazz {\n " + - " private Integer i;\n" + - " private java.lang.Integer j;\n" + - " }"; - - public static final String CLASS_WITH_COLLIDING_IMPORTS_WITH_JAVA_LANG_FIRST = - " package my.test;" + - "\n" + - " public class Clazz {\n " + - " private Integer i;\n" + - " private org.jboss.errai.codegen.test.model.Integer j;\n" + - " }"; - - public static final String CLASS_WITH_CLASS_COMMENT = - " package org.foo;" + - "" + - " // A foo-ish bar" + - " public class Bar {}"; -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/ContextBuilderTest.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/ContextBuilderTest.java deleted file mode 100644 index 6ac61a166f8..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/ContextBuilderTest.java +++ /dev/null @@ -1,250 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test; - -import java.util.List; - -import javax.enterprise.util.TypeLiteral; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Variable; -import org.jboss.errai.codegen.VariableReference; -import org.jboss.errai.codegen.builder.impl.ContextBuilder; -import org.jboss.errai.codegen.builder.impl.ObjectBuilder; -import org.jboss.errai.codegen.exception.InvalidTypeException; -import org.jboss.errai.codegen.literal.LiteralFactory; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.util.Stmt; -import org.junit.Assert; -import org.junit.Test; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -/** - * Tests the {@link org.jboss.errai.codegen.builder.impl.ContextBuilder} API. - * - * @author Christian Sadilek - */ -public class ContextBuilderTest extends AbstractCodegenTest { - - @Test - public void testDeclareVariableWithExactTypeProvided() { - String declaration = ContextBuilder.create() - .declareVariable("n", Integer.class) - .initializeWith(10) - .toJavaString(); - - assertEquals("failed to generate variable declaration using a literal initialization", - "Integer n = 10;", declaration); - } - - @Test - public void testDeclareVariableWithTypeLiteral() { - @SuppressWarnings("serial") - String declaration = ContextBuilder.create(Context.create().autoImport()) - .declareVariable("list", new TypeLiteral>() {}) - .finish() - .toJavaString(); - - assertEquals("failed to generate variable declaration using a type literal", - "List list;", declaration); - } - - @Test - public void testDeclareVariableWithIntegerTypeInference() { - String declaration = ContextBuilder.create() - .declareVariable("n") - .initializeWith(10) - .toJavaString(); - - assertEquals("failed to generate variable declaration using a literal initialization and type inference", - "Integer n = 10;", declaration); - } - - @Test - public void testDeclareVariableWithStringTypeInference() { - String declaration = ContextBuilder.create() - .declareVariable("n") - .initializeWith("10") - .toJavaString(); - - assertEquals("failed to generate variable declaration using a literal initialization and type inference", - "String n = \"10\";", declaration); - } - - @Test - public void testDeclareVariableWithImplicitTypeConversion() { - String declaration = ContextBuilder.create() - .declareVariable("n", Integer.class) - .initializeWith("10") - .toJavaString(); - - assertEquals("failed to generate variable declaration using a literal initialization and type conversion", - "Integer n = 10;", declaration); - } - - @Test - public void testDeclareVariableWithInvalidInitialization() { - try { - ContextBuilder.create() - .declareVariable("n", Integer.class) - .initializeWith("abc") - .toJavaString(); - fail("Expected InvalidTypeException"); - } - catch (InvalidTypeException ive) { - // expected - assertTrue(ive.getCause() instanceof NumberFormatException); - } - } - - @Test - public void testDeclareVariableWithObjectInitialization() { - String declaration = ContextBuilder.create() - .declareVariable("str", String.class) - .initializeWith(ObjectBuilder.newInstanceOf(String.class)) - .toJavaString(); - - assertEquals("failed to generate variable declaration using an objectbuilder initialization", - "String str = new String();", declaration); - } - - @Test - public void testDeclareVariableWithObjectInitializationWithParameters() { - String declaration = ContextBuilder.create() - .declareVariable("str", String.class) - .initializeWith(ObjectBuilder.newInstanceOf(String.class).withParameters("abc")) - .toJavaString(); - - assertEquals("failed to generate variable declaration using an objectbuilder initialization with parameters", - "String str = new String(\"abc\");", declaration); - } - - @Test - public void testDeclareVariableWithObjectInitializationUsingSuperClassType() { - - String declaration = ContextBuilder.create() - .declareVariable("str", Object.class) - .initializeWith(ObjectBuilder.newInstanceOf(String.class).withParameters("abc")) - .toJavaString(); - - assertEquals("failed to generate variable declaration using an objectbuilder initialization with parameters", - "Object str = new String(\"abc\");", declaration); - - try { - Stmt.declareVariable("str", Integer.class, ObjectBuilder.newInstanceOf(String.class).withParameters("abc")) - .toJavaString(); - fail("Expected InvalidTypeException"); - } - catch (InvalidTypeException e) { - // expected - } - - try { - Stmt.declareVariable("str", String.class, ObjectBuilder.newInstanceOf(Object.class)) - .toJavaString(); - fail("Expected InvalidTypeException"); - } - catch (InvalidTypeException e) { - // expected - } - } - - @Test - public void testAddVariableWithExactTypeProvided() { - Context ctx = ContextBuilder.create().addVariable("n", Integer.class, 10).getContext(); - - VariableReference n = ctx.getVariable("n"); - assertEquals("Wrong variable name", "n", n.getName()); - Assert.assertEquals("Wrong variable type", MetaClassFactory.get(Integer.class), n.getType()); - Assert.assertEquals("Wrong variable value", LiteralFactory.getLiteral(10), n.getValue()); - } - - @Test - public void testAddVariableWithIntegerTypeInference() { - Context ctx = ContextBuilder.create().addVariable("n", 10).getContext(); - - VariableReference n = ctx.getVariable("n"); - assertEquals("Wrong variable name", "n", n.getName()); - Assert.assertEquals("Wrong variable type", MetaClassFactory.get(Integer.class), n.getType()); - Assert.assertEquals("Wrong variable value", LiteralFactory.getLiteral(10), n.getValue()); - } - - @Test - public void testAddVariableWithStringTypeInference() { - Context ctx = ContextBuilder.create().addVariable("n", "10").getContext(); - - VariableReference n = ctx.getVariable("n"); - assertEquals("Wrong variable name", "n", n.getName()); - Assert.assertEquals("Wrong variable type", MetaClassFactory.get(String.class), n.getType()); - Assert.assertEquals("Wrong variable value", LiteralFactory.getLiteral("10"), n.getValue()); - } - - @Test - public void testAddVariableWithImplicitTypeConversion() { - Context ctx = ContextBuilder.create().addVariable("n", Integer.class, "10").getContext(); - - VariableReference n = ctx.getVariable("n"); - assertEquals("Wrong variable name", "n", n.getName()); - Assert.assertEquals("Wrong variable type", MetaClassFactory.get(Integer.class), n.getType()); - Assert.assertEquals("Wrong variable value", LiteralFactory.getLiteral(10), n.getValue()); - - try { - Stmt.create(ContextBuilder.create().addVariable("n", Integer.class, "abc").getContext()).toJavaString(); - fail("Expected InvalidTypeException"); - } - catch (InvalidTypeException ive) { - // expected - assertTrue(ive.getCause() instanceof NumberFormatException); - } - } - - @Test - public void testAddVariableWithObjectInitializationWithExactTypeProvided() { - Context ctx = ContextBuilder.create().addVariable("str", String.class, - ObjectBuilder.newInstanceOf(String.class)).getContext(); - - VariableReference str = ctx.getVariable("str"); - assertEquals("Wrong variable name", "str", str.getName()); - Assert.assertEquals("Wrong variable type", MetaClassFactory.get(String.class), str.getType()); - - // variable value cannot be verified before initialization statement was generated. - Variable v = ctx.getVariables().get("str"); - v.generate(ctx); - assertNotNull("Value could not be generated", v.getValue()); - } - - @Test - public void testAddVariableWithObjectInitializationWithStringTypeInference() { - Context ctx = ContextBuilder.create().addVariable("str", ObjectBuilder.newInstanceOf(String.class)).getContext(); - - VariableReference str = ctx.getVariable("str"); - assertEquals("Wrong variable name", "str", str.getName()); - - // variable type and value cannot be verified before initialization statement was generated. - Variable v = ctx.getVariables().get("str"); - v.generate(ctx); - assertNotNull("Value could not be generated", v.getValue()); - Assert.assertEquals("Wrong variable type", MetaClassFactory.get(String.class), v.getType()); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/IfBlockBuilderTest.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/IfBlockBuilderTest.java deleted file mode 100644 index 554bc9ab39c..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/IfBlockBuilderTest.java +++ /dev/null @@ -1,379 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test; - -import org.jboss.errai.codegen.ArithmeticOperator; -import org.jboss.errai.codegen.BooleanOperator; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Variable; -import org.jboss.errai.codegen.builder.impl.ContextBuilder; -import org.jboss.errai.codegen.builder.impl.StatementBuilder; -import org.jboss.errai.codegen.exception.InvalidExpressionException; -import org.jboss.errai.codegen.exception.InvalidTypeException; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.util.Arith; -import org.jboss.errai.codegen.util.Bool; -import org.jboss.errai.codegen.util.Refs; -import org.jboss.errai.codegen.util.Stmt; -import org.junit.Test; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -/** - * Tests the generation of if blocks using the {@link StatementBuilder} API. - * - * @author Christian Sadilek - */ -public class IfBlockBuilderTest extends AbstractCodegenTest implements IfBlockBuilderTestResult { - - @Test - public void testEmptyIfBlockUsingNoRhs() { - String s = StatementBuilder.create() - .declareVariable("str", String.class) - .loadVariable("str") - .invoke("endsWith", "abc") - .if_() - .finish().toJavaString(); - - assertEquals("Failed to generate empty if block using no rhs", EMPTY_IF_BLOCK_NO_RHS, s); - } - - @Test - public void testEmptyIfBlockUsingNoRhsAndNegation() { - String s = StatementBuilder.create() - .declareVariable("str", String.class) - .loadVariable("str") - .invoke("endsWith", "abc") - .ifNot() - .finish().toJavaString(); - - assertEquals("Failed to generate empty if block using no rhs", EMPTY_IF_BLOCK_NO_RHS_AND_NEGATION, s); - } - - @Test - public void testEmptyIfBlockUsingLiteralRhs() { - String s = StatementBuilder.create() - .declareVariable("n", int.class) - .loadVariable("n") - .if_(BooleanOperator.Equals, 1) - .finish().toJavaString(); - - assertEquals("Failed to generate empty if block using a literal rhs", EMPTY_IF_BLOCK_LITERAL_RHS, s); - } - - @Test - public void testIfElseBlockUsingNoRhs() { - String s = StatementBuilder.create() - .declareVariable("str", String.class) - .loadVariable("str") - .invoke("endsWith", "abc") - .if_() - ._(Stmt.declareVariable(Integer.class).named("n").initializeWith(0)) - .finish() - .else_() - ._(Stmt.declareVariable(Integer.class).named("n").initializeWith(1)) - .finish().toJavaString(); - - assertEquals("Failed to generate empty if block using no rhs", IF_ELSE_BLOCK_NO_RHS, s); - } - - @Test - public void testIfElseBlockUsingRhs() { - String s = StatementBuilder.create() - .declareVariable("n", Integer.class) - .declareVariable("m", Integer.class) - .loadVariable("n") - .if_(BooleanOperator.GreaterThan, Variable.get("m")) - ._(Stmt.declareVariable(Integer.class).named("n").initializeWith(0)) - .finish() - .else_() - ._(Stmt.declareVariable(Integer.class).named("n").initializeWith(1)) - .finish().toJavaString(); - - assertEquals("Failed to generate empty if block using a rhs", IF_ELSE_BLOCK_RHS, s); - } - - @Test - public void testNestedIfElseIfBlockUsingNoRhs() { - Context c = ContextBuilder.create().addVariable("s", String.class).addVariable("n", Integer.class).getContext(); - - String s = StatementBuilder.create(c) - .loadVariable("s") - .invoke("endsWith", "abc") - .if_() - ._(StatementBuilder.create(c).loadVariable("n").assignValue(0)) - .finish() - .else_() - ._(StatementBuilder.create(c).loadVariable("s") - .invoke("startsWith", "def") - .if_() - ._(StatementBuilder.create(c).loadVariable("n").assignValue(1)) - .finish() - ) - .finish().toJavaString(); - - assertEquals("Failed to generate if-else-if-block using no rhs", IF_ELSEIF_BLOCK_NO_RHS_NESTED, s); - } - - @Test - public void testNestedIfElseIfElseBlockUsingNoRhs() { - Context c = ContextBuilder.create().addVariable("s", String.class).addVariable("n", Integer.class).getContext(); - - String s = StatementBuilder.create(c) - .loadVariable("s") - .invoke("endsWith", "abc") - .if_() - .append(StatementBuilder.create(c).loadVariable("n").assignValue(0)) - .finish() - .else_() - .append(StatementBuilder.create(c).loadVariable("s") - .invoke("startsWith", "def") - .if_() - .append(StatementBuilder.create(c).loadVariable("n").assignValue(1)) - .finish() - .else_() - .append(StatementBuilder.create(c).loadVariable("n").assignValue(2)) - .finish() - ) - .finish().toJavaString(); - - assertEquals("Failed to generate if-else-if-else block using no rhs", - IF_ELSEIF_ELSE_BLOCK_NO_RHS_NESTED, s); - } - - @Test - public void testNestedIfElseIfBlockUsingRhs() { - Context c = ContextBuilder.create().addVariable("n", Integer.class).addVariable("m", Integer.class).getContext(); - - String s = StatementBuilder.create(c) - .loadVariable("n") - .if_(BooleanOperator.GreaterThan, Variable.get("m")) - .append(StatementBuilder.create(c).loadVariable("n").assignValue(0)) - .finish() - .else_() - .append(StatementBuilder.create(c).loadVariable("m") - .if_(BooleanOperator.GreaterThan, Variable.get("n")) - .append(StatementBuilder.create(c).loadVariable("n").assignValue(1)) - .finish() - .else_() - .append(StatementBuilder.create(c).loadVariable("n").assignValue(2)) - .finish() - ) - .finish().toJavaString(); - - assertEquals("Failed to generate if-else-if-else block using rhs", IF_ELSEIF_ELSE_BLOCK_RHS_NESTED, s); - } - - @Test - public void testIfElseIfBlockUsingNoRhsAndElseifKeyword() { - Context c = ContextBuilder.create().addVariable("s", String.class).addVariable("n", Integer.class).getContext(); - - String s = StatementBuilder.create(c) - .loadVariable("s") - .invoke("endsWith", "abc") - .if_() - .append(StatementBuilder.create(c).loadVariable("n").assignValue(0)) - .finish() - .elseif_(StatementBuilder.create(c).loadVariable("s").invoke("startsWith", "def")) - .append(StatementBuilder.create(c).loadVariable("n").assignValue(1)) - .finish().toJavaString(); - - assertEquals("Failed to generate if-elseif block using no rhs", IF_ELSEIF_BLOCK_NO_RHS, s); - } - - @Test - public void testIfElseIfElseBlockUsingNoRhsAndElseifKeyword() { - Context c = ContextBuilder.create().addVariable("s", String.class).addVariable("n", Integer.class).getContext(); - - String s = StatementBuilder.create(c) - .loadVariable("s") - .invoke("endsWith", "abc") - .if_() - .append(StatementBuilder.create(c).loadVariable("n").assignValue(0)) - .finish() - .elseif_(StatementBuilder.create(c).loadVariable("s").invoke("startsWith", "def")) - .append(StatementBuilder.create(c).loadVariable("n").assignValue(1)) - .finish() - .else_() - .append(StatementBuilder.create(c).loadVariable("n").assignValue(2)) - .finish().toJavaString(); - - assertEquals("Failed to generate if - elseif - else block using no rhs", IF_ELSEIF_ELSE_BLOCK_NO_RHS, s); - } - - @Test - public void testIfElseIfBlockUsingRhsAndElseifKeyword() { - Context c = ContextBuilder.create().addVariable("n", Integer.class).addVariable("m", Integer.class).getContext(); - - String s = StatementBuilder.create(c) - .loadVariable("n") - .if_(BooleanOperator.GreaterThan, Variable.get("m")) - .append(StatementBuilder.create(c).loadVariable("n").assignValue(0)) - .finish() - .elseif_(StatementBuilder.create(c).loadVariable("m"), BooleanOperator.GreaterThan, Variable.get("n")) - .append(StatementBuilder.create(c).loadVariable("n").assignValue(1)) - .finish() - .elseif_(StatementBuilder.create(c).loadVariable("m"), BooleanOperator.Equals, Variable.get("n")) - .append(StatementBuilder.create(c).loadVariable("n").assignValue(2)) - .finish() - .else_() - .append(StatementBuilder.create(c).loadVariable("n").assignValue(3)) - .finish().toJavaString(); - - assertEquals("Failed to generate if - else if - else block using rhs", IF_ELSEIF_ELSE_BLOCK_RHS, s); - } - - @Test - public void testIfBlockWithInvalidNonBooleanExpression() { - try { - StatementBuilder.create() - .declareVariable("str", String.class) - .loadVariable("str") - .invoke("compareTo", "asd") - .if_().finish() - .toJavaString(); - - fail("Expected InvalidTypeException"); - } - catch (InvalidTypeException e) { - // expected - } - - try { - StatementBuilder.create() - .declareVariable("str", String.class) - .loadVariable("str") - .ifNot() - .finish() - .toJavaString(); - - fail("Expected InvalidTypeException"); - } - catch (InvalidTypeException e) { - // expected - } - } - - @Test - public void testIfBlockWithInvalidExpression() { - try { - StatementBuilder.create() - .declareVariable("str", String.class) - .declareVariable("str2", String.class) - .loadVariable("str") - .if_(BooleanOperator.GreaterThan, Variable.get("str2")).finish() - .toJavaString(); - - fail("Expected InvalidExpressionException"); - } - catch (InvalidExpressionException e) { - // expected - assertTrue("Wrong exception thrown", e.getMessage().contains(String.class.getName())); - } - } - - @Test - public void testIfBlockWithInstanceOfExpression() { - String s = StatementBuilder.create() - .declareVariable("str", String.class) - .loadVariable("str") - .if_(BooleanOperator.InstanceOf, MetaClassFactory.getAsStatement(String.class)).finish() - .toJavaString(); - - assertEquals("Failed to generate empty if block using an instance of expression", - EMPTY_IF_BLOCK_INSTANCE_OF_RHS, s); - } - - @Test - public void testIfBlockWithNullCheck() { - String s = StatementBuilder.create() - .declareVariable("str", String.class) - .loadVariable("str") - .if_(BooleanOperator.NotEquals, null) - .finish() - .toJavaString(); - - assertEquals("Failed to generate if block using a null rhs", EMPTY_IF_BLOCK_NULL_RHS, s); - } - - @Test - public void testIfBlockUnchainedWithNestedExpressions() { - Context ctx = Context.create().addVariable("a", boolean.class) - .addVariable("b", boolean.class); - - String s = Stmt.create(ctx) - .if_(Bool.expr( - Bool.expr("foo", BooleanOperator.Equals, "bar"), - BooleanOperator.Or, - Bool.expr( - Bool.expr("cat", BooleanOperator.Equals, "dog"), - BooleanOperator.And, - Bool.expr("girl", BooleanOperator.NotEquals, "boy")))) - .finish() - .elseif_(Bool.expr(Stmt.loadVariable("a"), BooleanOperator.And, Stmt.loadVariable("b"))) - .append(Stmt.loadStatic(System.class, "out").invoke("println", Refs.get("a"))) - .finish() - .toJavaString(); - - assertEquals("Failed to generate if block using nested boolean expressions", - IF_ELSEIF_BLOCK_UNCHAINED_NESTED_EXPRESSIONS, s); - } - - @Test - public void testIfBlockUnchainedWithExpressionUsingNegation() { - Context ctx = Context.create().addVariable("a", boolean.class) - .addVariable("b", boolean.class); - - String s = - Stmt.create(ctx) - .if_(Bool.expr(Stmt.loadVariable("a"), BooleanOperator.And, Bool.expr(Stmt.loadVariable("b")).negate())) - .append(Stmt.loadStatic(System.class, "out").invoke("println", Refs.get("a"))) - .finish() - .toJavaString(); - - assertEquals("Failed to generate if block using nested boolean expressions", - IF_BLOCK_UNCHAINED_WITH_EXPRESSION_USING_NEGATION, s); - } - - @Test - public void testIfBlockUnchainedWithExpressionUsingArithmetics() { - Context ctx = Context.create() - .addVariable("a", Integer.class) - .addVariable("b", Integer.class) - .addVariable("c", Float.class); - - String s = - Stmt.create(ctx) - .if_(Bool.expr( - Arith.expr( - Arith.expr(Stmt.loadVariable("a"), ArithmeticOperator.Addition, Stmt.loadVariable("b")), - ArithmeticOperator.Division, - Stmt.loadVariable("c")), - BooleanOperator.GreaterThan, 1)) - .append(Stmt.loadStatic(System.class, "out").invoke("println", Refs.get("a"))) - .finish() - .toJavaString(); - - assertEquals("Failed to generate if block using arithmetic expressions", - IF_BLOCK_UNCHAINED_WITH_EXPRESSION_USING_ARITHMETICS, s); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/IfBlockBuilderTestResult.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/IfBlockBuilderTestResult.java deleted file mode 100644 index 05518128f34..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/IfBlockBuilderTestResult.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test; - -/** - * @author Christian Sadilek - */ -public interface IfBlockBuilderTestResult { - - public static final String EMPTY_IF_BLOCK_NO_RHS = - "if (str.endsWith(\"abc\")) { }\n"; - - public static final String EMPTY_IF_BLOCK_NO_RHS_AND_NEGATION = - "if (!(str.endsWith(\"abc\"))) { }\n"; - - public static final String EMPTY_IF_BLOCK_LITERAL_RHS = - "if (n == 1) { }\n"; - - public static final String EMPTY_IF_BLOCK_NULL_RHS = - "if (str != null) { }\n"; - - public static final String EMPTY_IF_BLOCK_INSTANCE_OF_RHS = - "if (str instanceof String) { }\n"; - - public static final String IF_ELSE_BLOCK_NO_RHS = - " if (str.endsWith(\"abc\")) { " + - " Integer n = 0;\n" + - "} else {" + - " \nInteger n = 1;\n" + - "}\n"; - - public static final String IF_ELSE_BLOCK_RHS = - " if (n > m) { " + - " Integer n = 0;\n" + - "} else {" + - " \nInteger n = 1;\n" + - "}\n"; - - public static final String IF_ELSEIF_BLOCK_NO_RHS_NESTED = - " if (s.endsWith(\"abc\")) {\n" + - " n = 0;\n" + - "} else {\n" + - " if (s.startsWith(\"def\")) { " + - " n = 1;\n" + - " }\n" + - "}\n"; - - public static final String IF_ELSEIF_BLOCK_NO_RHS = - " if (s.endsWith(\"abc\")) {\n" + - " n = 0;\n" + - "} else if (s.startsWith(\"def\")) { " + - " n = 1;\n" + - "}\n"; - - public static final String IF_ELSEIF_ELSE_BLOCK_NO_RHS_NESTED = - " if (s.endsWith(\"abc\")) {\n" + - " n = 0;\n" + - "} else {\n" + - " if (s.startsWith(\"def\")) { " + - " n = 1;\n" + - " } else { " + - " n = 2;\n" + - " }\n" + - "}\n"; - - public static final String IF_ELSEIF_ELSE_BLOCK_NO_RHS = - " if (s.endsWith(\"abc\")) {\n" + - " n = 0;\n" + - "} else if (s.startsWith(\"def\")) { " + - " n = 1;\n" + - "} else { " + - " n = 2;\n" + - "}\n"; - - public static final String IF_ELSEIF_ELSE_BLOCK_RHS_NESTED = - " if (n > m) {\n" + - " n = 0;\n" + - "} else {\n" + - " if (m > n) { " + - " n = 1;\n" + - " } else { " + - " n = 2;\n" + - " }\n" + - "}\n"; - - public static final String IF_ELSEIF_ELSE_BLOCK_RHS = - " if (n > m) {\n" + - " n = 0;\n" + - "} else if (m > n) { " + - " n = 1;\n" + - "} else if (m == n) { " + - " n = 2;\n" + - "} else { " + - " n = 3;\n" + - "}\n"; - - public static final String IF_ELSEIF_BLOCK_UNCHAINED_NESTED_EXPRESSIONS = - " if ((\"foo\" == \"bar\") || ((\"cat\" == \"dog\") && (\"girl\" != \"boy\"))) { " + - " } " + - "else if (a && b) {" + - " System.out.println(a); " + - "} "; - - public static final String IF_BLOCK_UNCHAINED_WITH_EXPRESSION_USING_NEGATION = - " if (a && (!(b))) {" + - " System.out.println(a); " + - "} "; - - public static final String IF_BLOCK_UNCHAINED_WITH_EXPRESSION_USING_ARITHMETICS = - " if (((a + b) / c) > 1) {" + - " System.out.println(a); " + - "} "; -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/InvocationBuilderTest.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/InvocationBuilderTest.java deleted file mode 100644 index 1a56b1c4ff2..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/InvocationBuilderTest.java +++ /dev/null @@ -1,368 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.enterprise.util.TypeLiteral; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Variable; -import org.jboss.errai.codegen.builder.impl.ContextBuilder; -import org.jboss.errai.codegen.builder.impl.StatementBuilder; -import org.jboss.errai.codegen.exception.InvalidTypeException; -import org.jboss.errai.codegen.exception.OutOfScopeException; -import org.jboss.errai.codegen.exception.UndefinedMethodException; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.meta.MetaMethod; -import org.jboss.errai.codegen.test.model.Foo; -import org.jboss.errai.codegen.util.Refs; -import org.junit.Test; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -/** - * Tests the generation of method invocations using the {@link StatementBuilder} API. - * - * @author Christian Sadilek - */ -@SuppressWarnings("serial") -public class InvocationBuilderTest extends AbstractCodegenTest { - - @Test - public void testSingleInvocation() { - String s = StatementBuilder.create() - .declareVariable("obj", Object.class) - .loadVariable("obj") - .invoke("toString") - .toJavaString(); - - assertEquals("Failed to generate invocation on variable", "obj.toString()", s); - } - - @Test - public void testChainedInvocations() { - String s = StatementBuilder.create() - .declareVariable("i", Integer.class) - .declareVariable("regex", String.class) - .declareVariable("replacement", String.class) - .loadVariable("i") - .invoke("toString") - .invoke("replaceAll", Variable.get("regex"), Variable.get("replacement")) - .toJavaString(); - - assertEquals("Failed to generate chained invocations on variable", - "i.toString().replaceAll(regex, replacement)", s); - } - - @Test - public void testInvokeWithLiteralParameters() { - String result = StatementBuilder.create().declareVariable("s", String.class) - .loadVariable("s").invoke("replaceAll", "foo", "foo\t\n").toJavaString(); - - assertEquals("Failed to generate invocation using literal parameters", - "s.replaceAll(\"foo\", \"foo\\t\\n\")", result); - } - - @Test - public void testInvokeOnLiteral() { - String result = StatementBuilder.create().loadLiteral("foo").invoke("toString").toJavaString(); - - assertEquals("Failed to generate invocation using literal parameters", - "\"foo\".toString()", result); - } - - @Test - public void testInvokeBestMatchingMethod() { - String s = StatementBuilder.create() - .declareVariable("n", Integer.class) - .loadVariable("n") - // 1 will be inferred to LiteralValue, equals(Integer.class) - // should be matched equals(Object.class) - .invoke("equals", 1) - .toJavaString(); - - assertEquals("Failed to generate invocation on matched method", "n.equals(1)", s); - } - - @Test - public void testInvokeUndefinedMethodOnVariable() { - try { - StatementBuilder.create() - .declareVariable("obj", Object.class) - .declareVariable("param", String.class) - .loadVariable("obj") - .invoke("undefinedMethod", Variable.get("param")) - .toJavaString(); - fail("expected UndefinedMethodException"); - } - catch (UndefinedMethodException udme) { - // expected - assertEquals("Wrong exception thrown", udme.getMethodName(), "undefinedMethod"); - } - } - - @Test - public void testInvokeChainedUndefinedMethod() { - try { - StatementBuilder.create() - .declareVariable("s", String.class) - .declareVariable("regex", String.class) - .declareVariable("replacement", String.class) - .loadVariable("s") - .invoke("replaceAll", Variable.get("regex"), Variable.get("replacement")) - .invoke("undefinedMethod", Variable.get("regex"), Variable.get("replacement")) - .toJavaString(); - fail("expected UndefinedMethodException"); - } - catch (UndefinedMethodException udme) { - // expected - assertEquals("Wrong exception thrown", udme.getMethodName(), "undefinedMethod"); - } - } - - @Test - public void testInvokeOnUndefinedVariable() { - try { - // injector undefined - StatementBuilder.create() - .loadVariable("injector") - .invoke("provide", Refs.get("param"), Refs.get("param2")) - .toJavaString(); - fail("expected OutOfScopeException"); - } - catch (OutOfScopeException oose) { - // expected - assertTrue("Wrong exception thrown", oose.getMessage().contains("injector")); - } - } - - @Test - public void testInvokeWithUndefinedVariable() { - try { - // param2 undefined - StatementBuilder.create() - .declareVariable("obj", Object.class) - .declareVariable("param", String.class) - .loadVariable("obj") - .invoke("undefinedMethod", Variable.get("param"), Variable.get("param2")) - .toJavaString(); - fail("expected OutOfScopeException"); - } - catch (OutOfScopeException oose) { - // expected - assertTrue(oose.getMessage().contains("param2")); - } - } - - @Test - public void testInvokeUsingStandardizedLoadVariableReference() { - Context context = ContextBuilder.create() - .addVariable("s", String.class) - .getContext(); - - String s = StatementBuilder.create(context) - .load(Variable.get("s")) - .invoke("toUpperCase").toJavaString(); - - assertEquals("Failed using load() passing a variable reference", "s.toUpperCase()", s); - } - - @Test - public void testInvokeUsingStandardizedLoadVariableInstance() { - Context context = ContextBuilder.create() - .addVariable("s", String.class) - .getContext(); - - Variable v = Variable.create("s", String.class); - String s = StatementBuilder.create(context) - .load(v) - .invoke("toUpperCase").toJavaString(); - - assertEquals("Failed using load() passing a variable instance", "s.toUpperCase()", s); - } - - @Test - public void testInvokeUsingStandardizedLoadLiteral() { - String s = StatementBuilder.create() - .load("foo") - .invoke("toUpperCase").toJavaString(); - - assertEquals("Failed injecting literal with load()", "\"foo\".toUpperCase()", s); - } - - @Test - public void testInvokeWithParameterTypeConversionOfIntegerToString() { - String s = StatementBuilder.create() - .declareVariable("str", String.class) - .loadVariable("str") - .invoke("endsWith", 123) - .toJavaString(); - - assertEquals("Failed to generate invocation with parameter type conversion", "str.endsWith(\"123\")", s); - } - - @Test - public void testInvokeWithParameterTypeConversionOfStringToInteger() { - String s = StatementBuilder.create() - .declareVariable("str", String.class) - .loadVariable("str") - .invoke("substring", "1", "3") - .toJavaString(); - - assertEquals("Failed to generate invocation with parameter type conversion", "str.substring(1, 3)", s); - } - - @Test - public void testInvokeWithParameterTypeConversionOfVariable() { - Context c = Context.create().addVariable("n", Integer.class, 123); - String s = StatementBuilder.create(c) - .declareVariable("str", String.class) - .loadVariable("str") - .invoke("endsWith", c.getVariable("n").getValue()) - .toJavaString(); - - assertEquals("Failed to generate invocation with parameter type conversion of variable", - "str.endsWith(\"123\")", s); - } - - @Test - public void testInvokeStaticMethod() { - String s = StatementBuilder.create() - .invokeStatic(Integer.class, "getInteger", "123") - .toJavaString(); - - assertEquals("Failed to generate static method invocation", "Integer.getInteger(\"123\")", s); - } - - @Test - public void testInvokeUndefinedStaticMethod() { - try { - StatementBuilder.create() - .invokeStatic(Integer.class, "intValue") - .toJavaString(); - fail("expected UndefinedMethodException"); - } - catch (UndefinedMethodException udme) { - // expected - assertEquals("Wrong exception details", udme.getMethodName(), "intValue"); - } - } - - @Test - public void testInvokeWithVariableReturnType() { - String s = - StatementBuilder.create(Context.create().autoImport()) - .declareVariable("s", String.class) - .declareVariable("str", String.class, - StatementBuilder.create().invokeStatic(Foo.class, "foo", Variable.get("s"))) - .toJavaString(); - - assertEquals("Failed to generate method invocation using variable return type", - "String str = Foo.foo(s);", s); - } - - @Test - public void testInvokeWithInvalidVariableReturnType() { - - try { - StatementBuilder.create(Context.create().autoImport()) - .declareVariable("list", new TypeLiteral>() { - }) - .declareVariable("n", Integer.class, - StatementBuilder.create().invokeStatic(Foo.class, "bar", Variable.get("list"))) - .toJavaString(); - fail("expected InvalidTypeException"); - } - catch (InvalidTypeException e) { - // expected - assertEquals("Wrong exception message", - "java.lang.Integer is not assignable from java.lang.String", e.getMessage()); - } - } - - @Test - public void testInvokeWithParameterizedListAndVariableReturnType() { - String s = - StatementBuilder.create(Context.create().autoImport()) - .declareVariable("list", new TypeLiteral>() { - }) - .declareVariable("str", String.class, - StatementBuilder.create().invokeStatic(Foo.class, "bar", Variable.get("list"))) - .toJavaString(); - - assertEquals("Failed to generate method invocation with variable return type inferred from List", - "String str = Foo.bar(list);", s); - } - - @Test - public void testInvokeWithNestedParameterizedListAndVariableReturnType() { - String s = - StatementBuilder.create(Context.create().autoImport()) - .declareVariable("n", int.class) - .declareVariable("list", new TypeLiteral>>>() { - }) - .declareVariable("str", String.class, - StatementBuilder.create().invokeStatic(Foo.class, "bar", Variable.get("n"), Variable.get("list"))) - .toJavaString(); - - assertEquals("Failed to generate method invocation with variable return type inferred from nested List", - "String str = Foo.bar(n, list);", s); - } - - @Test - public void testInvokeWithParameterizedMapAndVariableReturnType() { - String s = - StatementBuilder.create(Context.create().autoImport()) - .declareVariable("map", new TypeLiteral>() { - }) - .declareVariable("val", Integer.class, - StatementBuilder.create().invokeStatic(Foo.class, "bar", Variable.get("map"))) - .toJavaString(); - - assertEquals("Failed to generate method invocation with variable return type inferred from Map", - "Integer val = Foo.bar(map);", s); - } - - @Test - public void testInvokeWithParameterizedClassAndVariableReturnType() { - String s = - StatementBuilder.create(Context.create().autoImport()) - .declareVariable("set", Set.class, - StatementBuilder.create().invokeStatic(Foo.class, "baz", Set.class)) - .toJavaString(); - - assertEquals("Failed to generate method invocation with variable return type inferred from Class", - "Set set = Foo.baz(Set.class);", s); - } - - @Test - public void testLookupOfMethodWithArrayParameters() { - final MetaClass metaClass = MetaClassFactory.get(Arrays.class); - final MetaMethod equals = metaClass.getBestMatchingMethod("equals", Class[].class, Class[].class); - assertEquals("public boolean equals([[Ljava.lang.Object;, [Ljava.lang.Object;])", equals.toString()); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/LiteralTest.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/LiteralTest.java deleted file mode 100644 index cf64ce17f58..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/LiteralTest.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.literal.LiteralFactory; -import org.jboss.errai.codegen.test.model.Person; -import org.jboss.errai.codegen.test.model.PersonImpl; -import org.jboss.errai.codegen.util.Stmt; -import org.junit.Test; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotSame; - -/** - * @author Mike Brock - */ -public class LiteralTest extends AbstractCodegenTest { - - @Test - public void testIntegerLiteral() { - assertEquals("1234", LiteralFactory.getLiteral(1234).generate(Context.create())); - } - - @Test - public void testShortLiteral() { - assertEquals("1234", LiteralFactory.getLiteral((short) 1234).generate(Context.create())); - } - - @Test - public void testLongLiteral() { - assertEquals("1234L", LiteralFactory.getLiteral(1234L).generate(Context.create())); - } - - @Test - public void testDoubleLiteral() { - assertEquals("1234.567d", LiteralFactory.getLiteral(1234.567d).generate(Context.create())); - } - - @Test - public void testFloatLiteral() { - assertEquals("1234.567f", LiteralFactory.getLiteral(1234.567f).generate(Context.create())); - } - - @Test - public void testByteLiteral() { - assertEquals("72", LiteralFactory.getLiteral((byte) 72).generate(Context.create())); - } - - @Test - public void testBooleanLiteral() { - assertEquals("false", LiteralFactory.getLiteral(false).generate(Context.create())); - } - - @Test - public void testStringLiteral() { - final String expected = "\"The quick brown fox said \\\"how do you do?\\\"\\nNew line.\\rCarriage Return!" - + "\\t and a tab\""; - - final String input = "The quick brown fox said \"how do you do?\"\nNew line.\rCarriage Return!" - + "\t and a tab"; - - assertEquals(expected, LiteralFactory.getLiteral(input).generate(Context.create())); - } - - @Test - public void testStringArrayCreation() { - final String[][] input = new String[][]{{"Hello1", "Hello2"}, {"Hello3", "Hello4"}}; - final String expected = "new String[][] { { \"Hello1\", \"Hello2\" }, { \"Hello3\", \"Hello4\" } }"; - - assertEquals(expected, LiteralFactory.getLiteral(input).generate(Context.create())); - } - - /** - * This tests that any caching in LiteralFactory does not affect literal - * values generated from mutated arrays. - */ - @Test - public void testGenerateIntArrayThenModifyThenGenerateAgain() { - final int[] a = new int[] { 1, 2, 3, 4 }; - - assertEquals("new int[] { 1, 2, 3, 4 }", LiteralFactory.getLiteral(a).generate(Context.create())); - - a[0] = 10; - - assertEquals("new int[] { 10, 2, 3, 4 }", LiteralFactory.getLiteral(a).generate(Context.create())); - } - - /** - * This tests that any caching in LiteralFactory does not affect literal - * values generated from mutated arrays of identity-equality values. - */ - @Test - public void testGenerateObjectArrayThenModifyThenGenerateAgain() { - PersonImpl p = new PersonImpl("person", 1, null); - - { - // pre-flight check: this test is only effective if PersonImpl is equal-by-identity - // and not equal-by-value (that is, PersonImpl inherits Object.equals behaviour) - PersonImpl p2 = new PersonImpl("person", 1, null); - assertNotSame(p, p2); - assertFalse(p.equals(p2)); - } - - // now the test itself - final Person[] a = new Person[] { p }; - - Context ctx = Context.create(); - ctx.addLiteralizableClass(Person.class); - - assertEquals("new org.jboss.errai.codegen.test.model.Person[] { " + - "new org.jboss.errai.codegen.test.model.Person() { " + - "public int getAge() { return 1; } " + - "public org.jboss.errai.codegen.test.model.Person getMother() { return null; } " + - "public String getName() { return \"person\"; } } }", - LiteralFactory.getLiteral(a).generate(ctx)); - - p.setAge(10); - - assertEquals("new org.jboss.errai.codegen.test.model.Person[] { " + - "new org.jboss.errai.codegen.test.model.Person() { " + - "public int getAge() { return 10; } " + - "public org.jboss.errai.codegen.test.model.Person getMother() { return null; } " + - "public String getName() { return \"person\"; } } }", - LiteralFactory.getLiteral(a).generate(ctx)); - } - - - @Test - public void testClassLiteral() { - assertEquals("String.class", LiteralFactory.getLiteral(String.class).generate(Context.create())); - } - - @Test - public void testSetEncoding() { - Set s = new LinkedHashSet(); - s.add("foo"); - s.add("bar"); - - assertEquals("new java.util.HashSet() {\n" + - " {\n" + - " add(\"foo\");\n" + - " add(\"bar\");\n" + - " }\n" + - "}", Stmt.load(s).generate(Context.create())); - - } - - @Test - public void testListEncoding() { - List s = new ArrayList(); - s.add("foo"); - s.add("bar"); - - assertEquals("new java.util.ArrayList() {\n" + - " {\n" + - " add(\"foo\");\n" + - " add(\"bar\");\n" + - " }\n" + - "}", Stmt.load(s).generate(Context.create())); - - } - - @Test - public void testMapEncoding() { - Map s = new LinkedHashMap(); - s.put("foo", "fooz"); - s.put("bar", "barz"); - - assertEquals("new java.util.HashMap() {\n" + - " {\n" + - " put(\"foo\", \"fooz\");\n" + - " put(\"bar\", \"barz\");\n" + - " }\n" + - "}", Stmt.load(s).generate(Context.create())); - - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/LoopBuilderTest.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/LoopBuilderTest.java deleted file mode 100644 index 2d4358a4e51..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/LoopBuilderTest.java +++ /dev/null @@ -1,624 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test; - -import java.util.List; -import java.util.Map; - -import javax.enterprise.util.TypeLiteral; - -import org.jboss.errai.codegen.AssignmentOperator; -import org.jboss.errai.codegen.BooleanOperator; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.Variable; -import org.jboss.errai.codegen.builder.Builder; -import org.jboss.errai.codegen.builder.impl.ContextBuilder; -import org.jboss.errai.codegen.builder.impl.StatementBuilder; -import org.jboss.errai.codegen.exception.InvalidExpressionException; -import org.jboss.errai.codegen.exception.InvalidTypeException; -import org.jboss.errai.codegen.exception.OutOfScopeException; -import org.jboss.errai.codegen.exception.TypeNotIterableException; -import org.jboss.errai.codegen.util.Bool; -import org.jboss.errai.codegen.util.Stmt; -import org.junit.Test; - -import static org.jboss.errai.codegen.test.LoopBuilderTestResult.DOWHILE_NESTED_EXPRESSION; -import static org.jboss.errai.codegen.test.LoopBuilderTestResult.DOWHILE_SIMPLE_EXPRESSION; -import static org.jboss.errai.codegen.test.LoopBuilderTestResult.DOWHILE_SIMPLE_EXPRESSION_NO_OP; -import static org.jboss.errai.codegen.test.LoopBuilderTestResult.FOREACH_KEYSET_LOOP; -import static org.jboss.errai.codegen.test.LoopBuilderTestResult.FOREACH_LITERAL_STRING_ARRAY; -import static org.jboss.errai.codegen.test.LoopBuilderTestResult.FOREACH_NESTED_STRING_IN_LIST; -import static org.jboss.errai.codegen.test.LoopBuilderTestResult.FOREACH_OBJECT_IN_LIST; -import static org.jboss.errai.codegen.test.LoopBuilderTestResult.FOREACH_OBJECT_IN_LIST_NOT_NULL; -import static org.jboss.errai.codegen.test.LoopBuilderTestResult.FOREACH_OBJECT_IN_LIST_TWO_STATEMENTS; -import static org.jboss.errai.codegen.test.LoopBuilderTestResult.FOREACH_STRING_IN_ARRAY_ONE_STATEMENT; -import static org.jboss.errai.codegen.test.LoopBuilderTestResult.FOREACH_STRING_IN_LIST; -import static org.jboss.errai.codegen.test.LoopBuilderTestResult.FOREACH_STRING_IN_LIST_NOT_NULL; -import static org.jboss.errai.codegen.test.LoopBuilderTestResult.FOR_CHAINED_INITIALIZER_COUNTING_EXP_EMPTY; -import static org.jboss.errai.codegen.test.LoopBuilderTestResult.FOR_CHAINED_INITIALIZER_NO_COUNTING_EXP_EMPTY; -import static org.jboss.errai.codegen.test.LoopBuilderTestResult.FOR_DECLARE_INITIALIZER_COUNTING_EXP; -import static org.jboss.errai.codegen.test.LoopBuilderTestResult.FOR_INITIALIZER_COUNTING_EXP_EMPTY; -import static org.jboss.errai.codegen.test.LoopBuilderTestResult.FOR_INITIALIZER_NO_COUNTING_EXP_EMPTY; -import static org.jboss.errai.codegen.test.LoopBuilderTestResult.FOR_NO_INITIALIZER_NO_COUNTING_EXP_EMPTY; -import static org.jboss.errai.codegen.test.LoopBuilderTestResult.LOOP_WITH_BREAK; -import static org.jboss.errai.codegen.test.LoopBuilderTestResult.LOOP_WITH_BREAK_AND_LABEL; -import static org.jboss.errai.codegen.test.LoopBuilderTestResult.LOOP_WITH_CONTINUE; -import static org.jboss.errai.codegen.test.LoopBuilderTestResult.LOOP_WITH_CONTINUE_AND_LABEL; -import static org.jboss.errai.codegen.test.LoopBuilderTestResult.WHILE_EMPTY; -import static org.jboss.errai.codegen.test.LoopBuilderTestResult.WHILE_NESTED_EMPTY; -import static org.jboss.errai.codegen.test.LoopBuilderTestResult.WHILE_NESTED_LOOPS; -import static org.jboss.errai.codegen.test.LoopBuilderTestResult.WHILE_RHS_EMPTY; -import static org.jboss.errai.codegen.test.LoopBuilderTestResult.WHILE_RHS_NULL_EMPTY; -import static org.jboss.errai.codegen.test.LoopBuilderTestResult.WHILE_WITH_BODY; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -/** - * Tests the generation of loops using the {@link StatementBuilder} API. - * - * @author Christian Sadilek - */ -@SuppressWarnings("serial") -public class LoopBuilderTest extends AbstractCodegenTest { - - @Test - public void testForeachLoopWithStringInParameterizedList() { - String foreachWithListOfStrings = StatementBuilder.create() - .declareVariable("list", new TypeLiteral>() {}) - .loadVariable("list") - .foreach("element") - .finish().toJavaString(); - - assertEquals("Failed to generate foreach loop using a List", - FOREACH_STRING_IN_LIST, foreachWithListOfStrings); - } - - @Test - public void testForeachLoopWithStringInArray() { - Statement createObject = StatementBuilder.create().newObject(String.class); - - String foreachWithStringArray = StatementBuilder.create(Context.create().addVariable("list", String[].class)) - .loadVariable("list") - .foreach("element") - .append(createObject) - .finish() - .toJavaString(); - - assertEquals("Failed to generate foreach loop using a String[]", - FOREACH_STRING_IN_ARRAY_ONE_STATEMENT, foreachWithStringArray); - } - - @Test - public void testForeachLoopWithStringInList() { - Statement createObject = StatementBuilder.create().newObject(String.class); - Statement createAnotherObject = StatementBuilder.create().newObject(Object.class); - - String foreachWithList = StatementBuilder.create() - .declareVariable("list", List.class) - .loadVariable("list") - .foreach("element") - .append(createObject) - .append(createAnotherObject) - .finish().toJavaString(); - - assertEquals("Failed to generate foreach loop using a List", - FOREACH_OBJECT_IN_LIST_TWO_STATEMENTS, foreachWithList); - } - - @Test - public void testForeachLoopWithUndefinedCollection() { - try { - StatementBuilder.create() - .loadVariable("list") - .foreach("element", Integer.class) - .finish().toJavaString(); - - fail("Expected OutOfScopeException"); - } - catch (OutOfScopeException e) { - // expected - } - } - - @Test - public void testForeachLoopWithProvidedLoopVarType() { - Builder builder = StatementBuilder.create() - .declareVariable("list", new TypeLiteral>() {}) - .loadVariable("list") - .foreach("element", Object.class) - .finish(); - - assertEquals("Failed to generate foreach loop with provided loop var type", - FOREACH_OBJECT_IN_LIST, builder.toJavaString()); - - try { - StatementBuilder.create() - .declareVariable("list", new TypeLiteral>() {}) - .loadVariable("list") - .foreach("element", Integer.class) - .finish().toJavaString(); - - fail("Expected InvalidTypeException"); - } - catch (InvalidTypeException e) { - // expected - } - } - - @Test - public void testForeachLoopsNested() { - Statement createObject = StatementBuilder.create().newObject(String.class); - - Builder outerLoop = StatementBuilder.create() - .declareVariable("list", new TypeLiteral>() {}) - .loadVariable("list") - .foreach("element") - .append(StatementBuilder.create( - ContextBuilder.create().addVariable(Variable.create("anotherList", - new TypeLiteral>() {})).getContext()) - .loadVariable("anotherList") - .foreach("anotherElement") - .append(createObject) - .finish() - ).finish(); - - assertEquals("Failed to generate nested foreach loops", - FOREACH_NESTED_STRING_IN_LIST, outerLoop.toJavaString()); - } - - @Test - public void testForeachLoopWithInvalidCollectionType() { - - try { - StatementBuilder.create() - .declareVariable("list", String.class) - .loadVariable("list") - .foreach("element") - .finish().toJavaString(); - - fail("Expected TypeNotIterableException"); - } - catch (TypeNotIterableException e) { - // expected - } - } - - @Test - public void testForeachLoopWithInvoke() { - Builder loop = StatementBuilder.create() - .declareVariable("map", Map.class) - .loadVariable("map") - .invoke("keySet") - .foreach("key") - .append(Stmt.loadStatic(System.class, "out").invoke("println", Variable.get("key"))) - .finish(); - - assertEquals("Failed to generate foreach loop using invoke()", - FOREACH_KEYSET_LOOP, loop.toJavaString()); - } - - @Test - public void testForeachLoopWithLiterals() { - String s = StatementBuilder.create() - .loadLiteral(new String[] { "s1", "s2" }) - .foreach("s") - .append(StatementBuilder.create().loadVariable("s").invoke("getBytes")) - .finish().toJavaString(); - - assertEquals("Failed to generate foreach loop using a literal String array", - FOREACH_LITERAL_STRING_ARRAY, s); - } - - @Test - public void testForeachLoopWithProvidedContext() { - Context c = ContextBuilder.create().addVariable(Variable.create("s", String.class)).getContext(); - String s = StatementBuilder.create(c) - .loadLiteral(new String[] { "s1", "s2" }) - .foreach("s") - .append(StatementBuilder.create().loadVariable("s").invoke("getBytes")) - .finish().toJavaString(); - - assertEquals("Failed to generate foreach loop using a literal String array", - FOREACH_LITERAL_STRING_ARRAY, s); - } - - @Test - public void testForeachLoopWithNullCheck() { - String foreachWithListOfStrings = StatementBuilder.create() - .declareVariable("list", new TypeLiteral>() {}) - .loadVariable("list") - .foreachIfNotNull("element") - .finish().toJavaString(); - - assertEquals("Failed to generate foreach loop using a List and null check", - FOREACH_STRING_IN_LIST_NOT_NULL, foreachWithListOfStrings); - } - - @Test - public void testForeachLoopWithNullCheckAndProviderVarType() { - String foreachWithListOfStrings = StatementBuilder.create() - .declareVariable("list", new TypeLiteral>() {}) - .loadVariable("list") - .foreachIfNotNull("element", Object.class) - .finish().toJavaString(); - - assertEquals("Failed to generate foreach loop using a List and null check", - FOREACH_OBJECT_IN_LIST_NOT_NULL, foreachWithListOfStrings); - } - - @Test - public void testWhileLoopWithInvalidExpression() { - try { - StatementBuilder.create() - .declareVariable("n", Integer.class) - .loadVariable("n") - .while_().finish().toJavaString(); - fail("Expected InvalidTypeException"); - } - catch (InvalidTypeException e) { - // expected - } - - try { - StatementBuilder.create() - .declareVariable("str", String.class) - .declareVariable("str2", String.class) - .loadVariable("str") - .while_(BooleanOperator.GreaterThan, Variable.get("str2")).finish() - .toJavaString(); - - fail("Expected InvalidExpressionException"); - } - catch (InvalidExpressionException iee) { - // expected - assertTrue("Wrong exception thrown", iee.getMessage().contains(String.class.getName())); - } - } - - @Test - public void testWhileLoopChainedWithEmptyExpressionWithoutBody() { - String s = StatementBuilder.create() - .declareVariable("b", Boolean.class) - .loadVariable("b") - .while_().finish().toJavaString(); - - assertEquals("Failed to generate empty while loop with chained lhs", WHILE_EMPTY, s); - } - - @Test - public void testWhileLoopChainedWithEmptyExpressionWithBody() { - String s = StatementBuilder.create() - .declareVariable("b", Boolean.class) - .loadVariable("b") - .while_() - .append(StatementBuilder.create().loadVariable("b").assignValue(false)) - .finish().toJavaString(); - - assertEquals("Failed to generate while loop with chained lhs and body", WHILE_WITH_BODY, s); - } - - @Test - public void testWhileLoopChainedWithNullCheck() { - String s = StatementBuilder.create() - .declareVariable("str", String.class) - .loadVariable("str") - .while_(BooleanOperator.NotEquals, null) - .finish().toJavaString(); - - assertEquals("Failed to generate while loop with chained lhs, rhs (null check) and no body", - WHILE_RHS_NULL_EMPTY, s); - } - - @Test - public void testWhileLoopChainedWithExpression() { - String s = StatementBuilder.create() - .declareVariable("str", String.class) - .loadVariable("str") - .invoke("length") - .while_(BooleanOperator.GreaterThanOrEqual, 2) - .finish().toJavaString(); - - assertEquals("Failed to generate while loop with chained lhs, rhs and no body", WHILE_RHS_EMPTY, s); - } - - @Test - public void testWhileLoopUnchainedWithExpression() { - Context ctx = Context.create().addVariable("str", String.class); - String s = StatementBuilder.create(ctx) - .while_(Bool.expr(Stmt.loadVariable("str").invoke("length"), BooleanOperator.GreaterThanOrEqual, 2)) - .finish().toJavaString(); - - assertEquals("Failed to generate while loop with rhs and no body", WHILE_RHS_EMPTY, s); - } - - @Test - public void testWhileLoopUnchainedWithNestedExpressions() { - String s = StatementBuilder.create() - .declareVariable("str", String.class) - .while_(Bool.expr( - Bool.expr(Variable.get("str"), BooleanOperator.NotEquals, null), - BooleanOperator.And, - Bool.expr(Stmt.loadVariable("str").invoke("length"), BooleanOperator.GreaterThan, 0))) - .finish().toJavaString(); - - assertEquals("Failed to generate while loop with nested expressions and no body", WHILE_NESTED_EMPTY, s); - } - - @Test - public void testWhileLoopsNested() { - Context c = Context.create().addVariable("str", String.class).addVariable("str2", String.class); - - String s = StatementBuilder.create(c) - .loadVariable("str") - .while_(BooleanOperator.NotEquals, null) - .append( - StatementBuilder.create(c) - .while_(Bool.expr(Variable.get("str2"), BooleanOperator.NotEquals, null)) - .finish()) - .finish().toJavaString(); - - assertEquals("Failed to generate nested while loops", WHILE_NESTED_LOOPS, s); - } - - @Test - public void testForLoopUnchainedWithoutInitializerAndCountingExpression() { - String s = StatementBuilder.create() - .declareVariable("i", Integer.class, 0) - .for_(Bool.expr(Variable.get("i"), BooleanOperator.LessThan, 100)) - .finish().toJavaString(); - - assertEquals("Failed to generate for loop without initializer", - FOR_NO_INITIALIZER_NO_COUNTING_EXP_EMPTY, s); - } - - @Test - public void testForLoopChainedWithoutCountingExpression() { - String s = StatementBuilder.create() - .declareVariable("i", Integer.class, 0) - .loadVariable("i") - .for_(Stmt.loadVariable("i").assignValue(0), Bool.expr(BooleanOperator.LessThan, 100)) - .finish().toJavaString(); - - assertEquals("Failed to generate for loop with initializer and chained lhs", - FOR_CHAINED_INITIALIZER_NO_COUNTING_EXP_EMPTY, s); - } - - @Test - public void testForLoopUnchainedWithInitializer() { - String s = StatementBuilder.create() - .declareVariable("i", Integer.class) - .for_(StatementBuilder.create().loadVariable("i").assignValue(0), - Bool.expr(Variable.get("i"), BooleanOperator.LessThan, 100)) - .finish().toJavaString(); - - assertEquals("Failed to generate for loop with initializer", - FOR_INITIALIZER_NO_COUNTING_EXP_EMPTY, s); - } - - @Test - public void testForLoopChainedWithCountingExpression() { - String s = StatementBuilder.create() - .declareVariable("i", Integer.class, 0) - .loadVariable("i") - .for_(Stmt.loadVariable("i").assignValue(0), Bool.expr(BooleanOperator.LessThan, 100), - StatementBuilder.create().loadVariable("i").assignValue(AssignmentOperator.PreIncrementAssign, 1)) - .finish().toJavaString(); - - assertEquals("Failed to generate for loop with initializer and counting expression and chained lhs", - FOR_CHAINED_INITIALIZER_COUNTING_EXP_EMPTY, s); - } - - @Test - public void testForLoopUnchainedWithInitializerAndCountingExpression() { - String s = StatementBuilder.create() - .declareVariable("i", Integer.class) - .for_(StatementBuilder.create().loadVariable("i").assignValue(0), - Bool.expr(Variable.get("i"), BooleanOperator.LessThan, 100), - StatementBuilder.create().loadVariable("i").assignValue(AssignmentOperator.PreIncrementAssign, 1)) - .finish().toJavaString(); - - assertEquals("Failed to generate for loop with initializer and counting expression", - FOR_INITIALIZER_COUNTING_EXP_EMPTY, s); - } - - @Test - public void testForLoopUnchainedWithDeclaringInitializerAndCountingExpression() { - String s = StatementBuilder.create() - .for_(Stmt.declareVariable(int.class).named("i").initializeWith(0), - Bool.expr(Variable.get("i"), BooleanOperator.LessThan, 100), - StatementBuilder.create().loadVariable("i").assignValue(AssignmentOperator.PreIncrementAssign, 1)) - .append(StatementBuilder.create().loadStatic(System.class, "out").invoke("println", Variable.get("i"))) - .finish().toJavaString(); - - assertEquals("Failed to generate for loop with declaring initializer and counting expression", - FOR_DECLARE_INITIALIZER_COUNTING_EXP, s); - } - - @Test - public void testDoWhileLoopUnchainedWithoutRhs() { - String s = StatementBuilder.create() - .declareVariable("b", Boolean.class) - .do_() - .append(StatementBuilder.create().loadVariable("b").assignValue(false)) - .finish() - .while_(Bool.expr(Variable.get("b"))) - .toJavaString(); - - assertEquals("Failed to generate do while loop with simple expression (no operator and rhs)", - DOWHILE_SIMPLE_EXPRESSION_NO_OP, s); - } - - @Test - public void testDoWhileLoopChainedWithoutRhs() { - String s = StatementBuilder.create() - .declareVariable("b", Boolean.class) - .loadVariable("b") - .do_() - .append(StatementBuilder.create().loadVariable("b").assignValue(false)) - .finish() - .while_() - .toJavaString(); - - assertEquals("Failed to generate for do while loop with simple expression (no operator and rhs) and chained lhs", - DOWHILE_SIMPLE_EXPRESSION_NO_OP, s); - } - - @Test - public void testDoWhileLoopChainedWithRhs() { - String s = StatementBuilder.create() - .declareVariable("n", Integer.class) - .loadVariable("n") - .do_() - .append(StatementBuilder.create().loadVariable("n").assignValue(1)) - .finish() - .while_(BooleanOperator.GreaterThanOrEqual, 1) - .toJavaString(); - - assertEquals("Failed to generate for do while loop with simple expression (no operator and rhs) and chained lhs", - DOWHILE_SIMPLE_EXPRESSION, s); - } - - @Test - public void testDoWhileLoopUnchainedWithNestedExpressions() { - String s = StatementBuilder.create() - .declareVariable("str", String.class) - .do_() - .append(StatementBuilder.create().loadStatic(System.class, "out").invoke("println", Variable.get("str"))) - .finish() - .while_(Bool.expr( - Bool.expr(Variable.get("str"), BooleanOperator.NotEquals, null), - BooleanOperator.And, - Bool.expr(Stmt.loadVariable("str").invoke("length"), BooleanOperator.GreaterThan, 0))) - .toJavaString(); - - assertEquals("Failed to generate do while loop with nested expression", DOWHILE_NESTED_EXPRESSION, s); - } - - @Test - public void testLoopWithContinue() { - String s = StatementBuilder.create() - .declareVariable("i", Integer.class, 0) - .loadVariable("i") - .if_(BooleanOperator.GreaterThan, 100) - .append(Stmt - .for_(Stmt.loadVariable("i").assignValue(0), - Bool.expr(Variable.get("i"), BooleanOperator.LessThan, 100), - Stmt.loadVariable("i").assignValue(AssignmentOperator.PreIncrementAssign, 1)) - .append( - Stmt.if_(Bool.expr(Variable.get("i"), BooleanOperator.Equals, 50)) - .append(Stmt.continue_()) - .finish()) - .finish()) - .finish() - .toJavaString(); - - assertEquals("Failed to generate loop with continue", LOOP_WITH_CONTINUE, s); - } - - @Test - public void testLoopWithContinueAndLabel() { - String s = StatementBuilder.create() - .declareVariable("i", Integer.class, 0) - .loadVariable("i") - .if_(BooleanOperator.GreaterThan, 100) - .append(Stmt.label("label")) - .append(Stmt - .for_(Stmt.loadVariable("i").assignValue(0), - Bool.expr(Variable.get("i"), BooleanOperator.LessThan, 100), - Stmt.loadVariable("i").assignValue(AssignmentOperator.PreIncrementAssign, 1)) - .append(Stmt - .if_(Bool.expr(Variable.get("i"), BooleanOperator.Equals, 50)) - .append(Stmt.continue_("label")) - .finish()) - .finish()) - .finish() - .toJavaString(); - - assertEquals("Failed to generate loop with continue and label", LOOP_WITH_CONTINUE_AND_LABEL, s); - } - - @Test - public void testLoopWithBreak() { - String s = StatementBuilder.create() - .declareVariable("i", Integer.class, 0) - .loadVariable("i") - .if_(BooleanOperator.GreaterThan, 100) - .append(Stmt - .for_(Stmt.loadVariable("i").assignValue(0), - Bool.expr(Variable.get("i"), BooleanOperator.LessThan, 100), - Stmt.loadVariable("i").assignValue(AssignmentOperator.PreIncrementAssign, 1)) - .append(Stmt - .if_(Bool.expr(Variable.get("i"), BooleanOperator.Equals, 50)) - .append(Stmt.break_()) - .finish()) - .finish()) - .finish() - .toJavaString(); - - assertEquals("Failed to generate loop with continue", LOOP_WITH_BREAK, s); - } - - @Test - public void testLoopWithBreakAndLabel() { - String s = StatementBuilder.create() - .declareVariable("i", Integer.class, 0) - .loadVariable("i") - .if_(BooleanOperator.GreaterThan, 100) - .append(Stmt.label("label")) - .append(Stmt - .for_(Stmt.loadVariable("i").assignValue(0), - Bool.expr(Variable.get("i"), BooleanOperator.LessThan, 100), - Stmt.loadVariable("i").assignValue(AssignmentOperator.PreIncrementAssign, 1)) - .append(Stmt - .if_(Bool.expr(Variable.get("i"), BooleanOperator.Equals, 50)) - .append(Stmt.break_("label")) - .finish()) - .finish()) - .finish() - .toJavaString(); - - assertEquals("Failed to generate loop with continue and label", LOOP_WITH_BREAK_AND_LABEL, s); - } - - @Test - public void testLoopWithInvalidLabel() { - try { - StatementBuilder.create() - .declareVariable("i", Integer.class, 0) - .loadVariable("i") - .if_(BooleanOperator.GreaterThan, 100) - .append(Stmt.label("label")) - .append(Stmt - .for_(Stmt.loadVariable("i").assignValue(0), - Bool.expr(Variable.get("i"), BooleanOperator.LessThan, 100), - Stmt.loadVariable("i").assignValue(AssignmentOperator.PreIncrementAssign, 1)) - .append(Stmt.continue_("undefinedlabel")) - .finish()) - .finish() - .toJavaString(); - fail("expected OutOfScopeException"); - } - catch (OutOfScopeException e) { - // expected - } - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/LoopBuilderTestResult.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/LoopBuilderTestResult.java deleted file mode 100644 index bcacfef1e3b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/LoopBuilderTestResult.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test; - -/** - * Expected test results for the {@link LoopBuilderTest} - * - * @author Christian Sadilek - */ -public interface LoopBuilderTestResult { - - public static final String FOREACH_STRING_IN_LIST = - " for (String element : list) {" + - "\n}"; - - public static final String FOREACH_STRING_IN_LIST_NOT_NULL = - " if (list != null) {\n" + - " for (String element : list) {" + - "\n}" + - "\n}"; - - public static final String FOREACH_OBJECT_IN_LIST_NOT_NULL = - " if (list != null) {\n" + - " for (Object element : list) {" + - "\n}" + - "\n}"; - - public static final String FOREACH_STRING_IN_ARRAY_ONE_STATEMENT = - " for (String element : list) {" + - " \nnew String();" + - "\n}"; - - public static final String FOREACH_OBJECT_IN_LIST_TWO_STATEMENTS = - " for (Object element : list) {" + - " \nnew String();" + - " \nnew Object();" + - "\n}"; - - public static final String FOREACH_OBJECT_IN_LIST = - " for (Object element : list) {" + - "\n}"; - - public static final String FOREACH_NESTED_STRING_IN_LIST = - " for (String element : list) {" + - " \nfor (String anotherElement : anotherList) {" + - " \nnew String();" + - " \n}" + - "\n}"; - - public static final String FOREACH_KEYSET_LOOP = - " for (Object key : map.keySet()) {" + - " System.out.println(key);" + - "\n}"; - - public static final String FOREACH_LITERAL_STRING_ARRAY = - " for (String s : new String[] {\"s1\", \"s2\"}) {" + - " \ns.getBytes();" + - "\n}"; - - public static final String WHILE_EMPTY = - " while (b) { }"; - - public static final String WHILE_WITH_BODY = - " while (b) {\nb = false;\n}"; - - public static final String WHILE_RHS_NULL_EMPTY = - " while (str != null) { }"; - - public static final String WHILE_RHS_EMPTY = - " while (str.length() >= 2) { }"; - - public static final String WHILE_NESTED_EMPTY = - " while ((str != null) && (str.length() > 0)) { }"; - - public static final String WHILE_NESTED_LOOPS = - " while (str != null) { " + - " while (str2 != null) {" + - " }\n" + - "}"; - - public static final String FOR_NO_INITIALIZER_NO_COUNTING_EXP_EMPTY = - " for (; i < 100; ) { }"; - - public static final String FOR_INITIALIZER_NO_COUNTING_EXP_EMPTY = - " for (i = 0; i < 100; ) { }"; - - public static final String FOR_INITIALIZER_COUNTING_EXP_EMPTY = - " for (i = 0; i < 100; i += 1) { }"; - - public static final String FOR_CHAINED_INITIALIZER_NO_COUNTING_EXP_EMPTY = - " for (i = 0; i < 100; ) { }"; - - public static final String FOR_CHAINED_INITIALIZER_COUNTING_EXP_EMPTY = - " for (i = 0; i < 100; i += 1) { }"; - - public static final String FOR_DECLARE_INITIALIZER_COUNTING_EXP = - " for (int i = 0; i < 100; i += 1) { System.out.println(i); }"; - - public static final String DOWHILE_SIMPLE_EXPRESSION_NO_OP = - " do { b = false; } while (b);"; - - public static final String DOWHILE_SIMPLE_EXPRESSION = - " do { n = 1; } while (n >= 1);"; - - public static final String DOWHILE_NESTED_EXPRESSION = - " do { System.out.println(str); } while ((str != null) && (str.length() > 0));"; - - public static final String LOOP_WITH_CONTINUE = - " if (i > 100) {" + - " for (i = 0; i < 100; i += 1) { " + - " if (i == 50) {" + - " continue;" + - " }" + - " }\n" + - "\n}"; - - public static final String LOOP_WITH_CONTINUE_AND_LABEL = - " if (i > 100) {" + - " label:" + - " for (i = 0; i < 100; i += 1) { " + - " if (i == 50) {" + - " continue label;" + - " }" + - " }\n" + - "\n}"; - - public static final String LOOP_WITH_BREAK = - " if (i > 100) {" + - " for (i = 0; i < 100; i += 1) { " + - " if (i == 50) {" + - " break;" + - " }" + - " }\n" + - "\n}"; - - public static final String LOOP_WITH_BREAK_AND_LABEL = - " if (i > 100) {" + - " label:" + - " for (i = 0; i < 100; i += 1) { " + - " if (i == 50) {" + - " break label;" + - " }" + - " }\n" + - "\n}"; -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/ProxyMakerTest.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/ProxyMakerTest.java deleted file mode 100644 index e6bf444f7c9..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/ProxyMakerTest.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test; - -import java.util.Arrays; -import java.util.List; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.InnerClass; -import org.jboss.errai.codegen.ProxyMaker; -import org.jboss.errai.codegen.test.model.ToProxyBean; -import org.junit.Assert; -import org.junit.Test; - -import static org.junit.Assert.assertTrue; - -/** - * Tests for the {@link ProxyMaker}. - * - * @author Christian Sadilek - */ -public class ProxyMakerTest extends AbstractCodegenTest { - - /** - * Because JDK7 doesn't return reflection members in the order they were - * declared in source, we have to make a list of all the expected chunks in - * the generated sources, then verify that they were all present while - * ignoring the order of the fields and methods. - */ - private static final List expectedChunks = Arrays.asList( - "public class ToProxy_Proxy extends org.jboss.errai.codegen.test.model.ToProxyBean {\n" + - " private org.jboss.errai.codegen.test.model.ToProxyBean $$_proxy_$$;\n", - " private boolean $$_init_$$;\n", - - " @Override public String getName() {\n" + - " if ($$_init_$$) {\n" + - " return $$_proxy_$$.getName();\n" + - " } else {\n" + - " return null;\n" + - " }\n" + - " }\n", - - " @Override public org.jboss.errai.codegen.test.model.Integer getBlah() {\n" + - " if ($$_init_$$) {\n" + - " return $$_proxy_$$.getBlah();\n" + - " } else {\n" + - " return null;\n" + - " }\n" + - " }\n", - - " @Override public void methodWithTypeArgs(Class a0, com.google.common.collect.Multimap a1) {\n" + - " if ($$_init_$$) {\n" + - " $$_proxy_$$.methodWithTypeArgs(a0, a1);\n" + - " }\n" + - " }\n", - - " @Override public String toString() {\n" + - " if ($$_init_$$) {\n" + - " return $$_proxy_$$.toString();\n" + - " } else {\n" + - " return null;\n" + - " }\n" + - " }\n", - - " @Override public int hashCode() {\n" + - " if ($$_proxy_$$ == null) {\n" + - " throw new IllegalStateException(\"call to hashCode() on an unclosed proxy.\");\n" + - " } else {\n" + - " return $$_proxy_$$.hashCode();\n" + - " }\n" + - " }\n", - - " @Override public boolean equals(Object o) {\n" + - " if ($$_proxy_$$ == null) {\n" + - " throw new IllegalStateException(\"call to equals() on an unclosed proxy.\");\n" + - " } else {\n" + - " return $$_proxy_$$.equals(o);\n" + - " }\n" + - " }\n", - - " public void __$setProxiedInstance$(org.jboss.errai.codegen.test.model.ToProxyBean proxy) {\n" + - " $$_proxy_$$ = proxy;\n" + - " $$_init_$$ = true;\n" + - " }\n", - "}\n"); - - @Test - public void testProxyGeneration() { - String proxy = new InnerClass(ProxyMaker.makeProxy("ToProxy_Proxy", ToProxyBean.class)).generate(Context.create()); - - int totalChars = 0; - for (String expectedChunk : expectedChunks) { - assertTrue("Generated code was missing a chunk:\n" + expectedChunk + "\n----- Actual generated proxy was:\n" + proxy, - proxy.contains(expectedChunk)); - totalChars += countNonWhitespace(expectedChunk); - } - - // finally, a length check will ensure there were no extra chunks we weren't expecting - Assert.assertEquals( - "Found wrong number of non-whitespace chars in generated proxy:\n" + proxy, - totalChars, countNonWhitespace(proxy)); - } - - private static int countNonWhitespace(String s) { - return s.replaceAll("\\s", "").length(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/ReachabilityTest.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/ReachabilityTest.java deleted file mode 100644 index 6ef9eb57a50..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/ReachabilityTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test; - -import java.io.File; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -import com.google.common.io.CharStreams; -import org.jboss.errai.codegen.test.model.BeanWithTypeParmedMeths; -import org.jboss.errai.codegen.test.model.FakeBean; -import org.jboss.errai.codegen.util.QuickDeps; -import org.junit.Assert; -import org.junit.Test; - -/** - * @author Mike Brock - */ -public class ReachabilityTest { - - private static String getSource(Class clazz) throws Exception { - final String pathSeparator = File.separator; - final String name = clazz.getName().replace('.', pathSeparator.charAt(0)) + ".java"; - final InputStream inputStream = clazz.getClassLoader().getResourceAsStream(name); - - if (inputStream == null) { - throw new RuntimeException("not found: " + name); - } - - return CharStreams.toString(new InputStreamReader(inputStream)); - } - - @Test - public void testBasicReachability() throws Exception { - final String source = getSource(BeanWithTypeParmedMeths.class); - - final Set quickTypeDependencyList - = QuickDeps.getQuickTypeDependencyList(source, BeanWithTypeParmedMeths.class.getClassLoader()); - - final Set expected = new HashSet( - Arrays.asList( - "org.jboss.errai.codegen.test.model.BeanWithTypeParmedMeths", - "org.jboss.errai.codegen.test.model.Foo", - "org.jboss.errai.codegen.test.model.Bar", - "java.util.Map" - ) - ); - - Assert.assertEquals(expected, quickTypeDependencyList); - } - - @Test - public void testBasicReachability2() throws Exception { - final String source = getSource(FakeBean.class); - - final Set quickTypeDependencyList - = QuickDeps.getQuickTypeDependencyList(source, FakeBean.class.getClassLoader()); - - System.out.println(quickTypeDependencyList); - - final Set expected = new HashSet( - Arrays.asList( - "org.jboss.errai.codegen.test.model.FakeBean", - "javax.enterprise.inject.Instance", - "javax.inject.Inject", - "org.jboss.errai.codegen.test.model.Bar", - "org.jboss.errai.codegen.test.model.Bwah", - BigDecimal.class.getName(), - BigInteger.class.getName(), - String.class.getName(), - Class.class.getName() - ) - ); - - Assert.assertEquals(expected, quickTypeDependencyList); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/SnapshotMakerTest.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/SnapshotMakerTest.java deleted file mode 100644 index 27e5185aca5..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/SnapshotMakerTest.java +++ /dev/null @@ -1,289 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test; - -import java.util.Arrays; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.SnapshotMaker; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.builder.BlockBuilder; -import org.jboss.errai.codegen.builder.ClassStructureBuilder; -import org.jboss.errai.codegen.builder.impl.ClassBuilder; -import org.jboss.errai.codegen.exception.CyclicalObjectGraphException; -import org.jboss.errai.codegen.meta.MetaMethod; -import org.jboss.errai.codegen.test.model.Person; -import org.jboss.errai.codegen.test.model.PersonImpl; -import org.jboss.errai.codegen.test.model.SnapshotInterfaceWithCollections; -import org.jboss.errai.codegen.test.model.SnapshotInterfaceWithCollectionsImpl; -import org.jboss.errai.codegen.util.Stmt; -import org.junit.Assert; -import org.junit.Test; - -import static org.junit.Assert.assertTrue; - -// Note: extends from AbstractCodeGenTest to inherit overridden assertEquals(String, String) methods which are whitespace -// insensitive. -public class SnapshotMakerTest extends AbstractCodegenTest { - - @Test - public void testGenerateSnapshotOfMethod() throws Exception { - Person mother = new PersonImpl("mom", 30, null); - Person child = new PersonImpl("kid", 5, mother); - Statement snapshotStmt = SnapshotMaker.makeSnapshotAsSubclass(child, Person.class, Person.class, null, Person.class); - - final String generated - = snapshotStmt.generate(Context.create()); - - final String expectedValue = - "new org.jboss.errai.codegen.test.model.Person() {\n" + - " public int getAge() {\n" + - " return 5;\n" + - " }\n" + - " public org.jboss.errai.codegen.test.model.Person getMother() {\n" + - " return new org.jboss.errai.codegen.test.model.Person() {\n" + - " public int getAge() {\n" + - " return 30;\n" + - " }\n" + - " public org.jboss.errai.codegen.test.model.Person getMother() {\n" + - " return null;\n" + - " }\n" + - " public String getName() {\n" + - " return \"mom\";\n" + - " }\n" + - " };\n" + - " }\n" + - " public String getName() {\n" + - " return \"kid\";\n" + - " }\n" + - "}"; - - assertEquals(expectedValue, generated); - } - - @Test - public void testNoStackOverflowOnObjectCycle() { - PersonImpl cycle1 = new PersonImpl("cycle1", 30, null); - Person cycle2 = new PersonImpl("cycle2", 5, cycle1); - cycle1.setMother(cycle2); - - try { - Statement snapshotStmt = SnapshotMaker.makeSnapshotAsSubclass(cycle2, Person.class, Person.class, null, Person.class); - snapshotStmt.generate(Context.create()); - Assert.fail("Instance cycle was not detected"); - } - catch (CyclicalObjectGraphException e) { - assertTrue(e.getObjectsInvolvedInCycle().contains(cycle1)); - assertTrue(e.getObjectsInvolvedInCycle().contains(cycle2)); - } - } - - /** - * This test confirms the SnapshotMaker is called automatically by the code generator's literal reification logic - * for interfaces and classes explicitly market "literalizable" in the context. - * - * @throws Exception - */ - @Test - public void testCollectionsLiteralizableInSnapshots() throws Exception { - Person jonathan = new PersonImpl("Jonathan F.", 20, new PersonImpl("Jonathans's Parent", 50, null)); - Person christian = new PersonImpl("Christian S.", 20, new PersonImpl("Christians's Parent", 50, null)); - Person mike = new PersonImpl("Mike B.", 0, new PersonImpl("Mike's Parent", 50, null)); - - SnapshotInterfaceWithCollections personCollection - = new SnapshotInterfaceWithCollectionsImpl(Arrays.asList(jonathan, christian, mike)); - - // create a manual context - final Context ctx = Context.create(); - - // tell the code generator that classes that implement these interfaces are literalizable - ctx.addLiteralizableClass(SnapshotInterfaceWithCollections.class); - ctx.addLiteralizableClass(Person.class); - - // initialize a new builder with this context and try and build 'snapshot' as a code snapshot - final String generated = Stmt.create(ctx).load(personCollection).toJavaString(); - - final String expectedValue = - "new org.jboss.errai.codegen.test.model.SnapshotInterfaceWithCollections() {\n" + - " public java.util.List getPersons() {\n" + - " return new java.util.ArrayList() {\n" + - " {\n" + - " add(new org.jboss.errai.codegen.test.model.Person() {\n" + - " public int getAge() {\n" + - " return 20;\n" + - " }\n" + - " public org.jboss.errai.codegen.test.model.Person getMother() {\n" + - " return new org.jboss.errai.codegen.test.model.Person() {\n" + - " public int getAge() {\n" + - " return 50;\n" + - " }\n" + - " public org.jboss.errai.codegen.test.model.Person getMother() {\n" + - " return null;\n" + - " }\n" + - " public String getName() {\n" + - " return \"Jonathans's Parent\";\n" + - " }\n" + - " };\n" + - " }\n" + - " public String getName() {\n" + - " return \"Jonathan F.\";\n" + - " }\n" + - " });\n" + - " add(new org.jboss.errai.codegen.test.model.Person() {\n" + - " public int getAge() {\n" + - " return 20;\n" + - " }\n" + - " public org.jboss.errai.codegen.test.model.Person getMother() {\n" + - " return new org.jboss.errai.codegen.test.model.Person() {\n" + - " public int getAge() {\n" + - " return 50;\n" + - " }\n" + - " public org.jboss.errai.codegen.test.model.Person getMother() {\n" + - " return null;\n" + - " }\n" + - " public String getName() {\n" + - " return \"Christians's Parent\";\n" + - " }\n" + - " };\n" + - " }\n" + - " public String getName() {\n" + - " return \"Christian S.\";\n" + - " }\n" + - " });\n" + - " add(new org.jboss.errai.codegen.test.model.Person() {\n" + - " public int getAge() {\n" + - " return 0;\n" + - " }\n" + - " public org.jboss.errai.codegen.test.model.Person getMother() {\n" + - " return new org.jboss.errai.codegen.test.model.Person() {\n" + - " public int getAge() {\n" + - " return 50;\n" + - " }\n" + - " public org.jboss.errai.codegen.test.model.Person getMother() {\n" + - " return null;\n" + - " }\n" + - " public String getName() {\n" + - " return \"Mike's Parent\";\n" + - " }\n" + - " };\n" + - " }\n" + - " public String getName() {\n" + - " return \"Mike B.\";\n" + - " }\n" + - " });\n" + - " }\n" + - " };\n" + - " }\n" + - "}\n"; - - assertEquals(expectedValue, generated); - } - - @Test - public void testMethodBodyCallback() { - Person mom = new PersonImpl("mom", 30, null); - Person kid1 = new PersonImpl("Kid 1", 3, mom); - Person kid2 = new PersonImpl("Kid 2", 4, mom); - Person kid3 = new PersonImpl("Kid 3", 5, mom); - - ClassStructureBuilder peopleClassBuilder = ClassBuilder.define("com.foo.People").publicScope().body(); - BlockBuilder method = peopleClassBuilder.publicMethod(void.class, "makePeople").body(); - - Statement momVar = Stmt - .declareVariable(Person.class) - .asFinal() - .named("mom") - .initializeWith(SnapshotMaker.makeSnapshotAsSubclass(mom, Person.class, Person.class, null, Person.class)); - method.append(momVar); - - SnapshotMaker.MethodBodyCallback mbcb = new SnapshotMaker.MethodBodyCallback() { - @Override - public Statement generateMethodBody(MetaMethod method, Object o, ClassStructureBuilder containingClass) { - if (method.getName().equals("getMother")) { - return Stmt.loadVariable("mom").returnValue(); - } - return null; - } - }; - - method.append(Stmt.declareVariable("kid1", SnapshotMaker.makeSnapshotAsSubclass(kid1, Person.class, Person.class, mbcb, Person.class))); - method.append(Stmt.declareVariable("kid2", SnapshotMaker.makeSnapshotAsSubclass(kid2, Person.class, Person.class, mbcb, Person.class))); - method.append(Stmt.declareVariable("kid3", SnapshotMaker.makeSnapshotAsSubclass(kid3, Person.class, Person.class, mbcb, Person.class))); - - method.finish(); - - final String generated = peopleClassBuilder.toJavaString(); - - String expected = "package com.foo;\n" + - "\n" + - "import org.jboss.errai.codegen.test.model.Person;\n" + - "\n" + - "public class People {\n" + - " public void makePeople() {\n" + - " final Person mom = new Person() {\n" + - " public int getAge() {\n" + - " return 30;\n" + - " }\n" + - " public Person getMother() {\n" + - " return null;\n" + - " }\n" + - " public String getName() {\n" + - " return \"mom\";\n" + - " }\n" + - " };\n" + - " Person kid1 = new Person() {\n" + - " public int getAge() {\n" + - " return 3;\n" + - " }\n" + - " public Person getMother() {\n" + - " return mom;\n" + - " }\n" + - " public String getName() {\n" + - " return \"Kid 1\";\n" + - " }\n" + - " };\n" + - " Person kid2 = new Person() {\n" + - " public int getAge() {\n" + - " return 4;\n" + - " }\n" + - " public Person getMother() {\n" + - " return mom;\n" + - " }\n" + - " public String getName() {\n" + - " return \"Kid 2\";\n" + - " }\n" + - " };\n" + - " Person kid3 = new Person() {\n" + - " public int getAge() {\n" + - " return 5;\n" + - " }\n" + - " public Person getMother() {\n" + - " return mom;\n" + - " }\n" + - " public String getName() {\n" + - " return \"Kid 3\";\n" + - " }\n" + - " };\n" + - " }\n" + - "}\n"; - assertEquals(expected, generated); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/StatementBuilderTest.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/StatementBuilderTest.java deleted file mode 100644 index fa4154ec415..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/StatementBuilderTest.java +++ /dev/null @@ -1,660 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test; - -import java.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; - -import javax.annotation.PostConstruct; -import javax.enterprise.util.TypeLiteral; -import javax.inject.Inject; - -import org.jboss.errai.codegen.AssignmentOperator; -import org.jboss.errai.codegen.Cast; -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.Statement; -import org.jboss.errai.codegen.Variable; -import org.jboss.errai.codegen.VariableReference; -import org.jboss.errai.codegen.builder.ContextualStatementBuilder; -import org.jboss.errai.codegen.builder.impl.ObjectBuilder; -import org.jboss.errai.codegen.builder.impl.StatementBuilder; -import org.jboss.errai.codegen.exception.InvalidTypeException; -import org.jboss.errai.codegen.exception.OutOfScopeException; -import org.jboss.errai.codegen.exception.UndefinedFieldException; -import org.jboss.errai.codegen.literal.LiteralFactory; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.test.model.BeanWithTypeParmedMeths; -import org.jboss.errai.codegen.test.model.Foo; -import org.jboss.errai.codegen.test.model.TEnum; -import org.jboss.errai.codegen.util.Bitwise; -import org.jboss.errai.codegen.util.Bool; -import org.jboss.errai.codegen.util.Expr; -import org.jboss.errai.codegen.util.Refs; -import org.jboss.errai.codegen.util.Stmt; -import org.junit.Assert; -import org.junit.Test; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -/** - * Tests the {@link StatementBuilder} API. - * - * @author Christian Sadilek - */ -public class StatementBuilderTest extends AbstractCodegenTest { - - @Test - public void testDeclareVariableWithExactTypeProvided() { - final Context ctx = Context.create(); - final String s = StatementBuilder.create().declareVariable("n", Integer.class, 10).generate(ctx); - - assertEquals("failed to generate variable declaration with type provided", - "Integer n = 10;", s); - - final VariableReference n = ctx.getVariable("n"); - assertEquals("Wrong variable name", "n", n.getName()); - Assert.assertEquals("Wrong variable type", MetaClassFactory.get(Integer.class), n.getType()); - Assert.assertEquals("Wrong variable value", LiteralFactory.getLiteral(10), n.getValue()); - } - - @Test - public void testDeclareVariableWithIntegerTypeInference() { - final Context ctx = Context.create(); - final String s = StatementBuilder.create().declareVariable("n", 10).generate(ctx); - - assertEquals("failed to generate variable declaration with Integers type inference", - "Integer n = 10;", s); - - final VariableReference n = ctx.getVariable("n"); - assertEquals("Wrong variable name", "n", n.getName()); - Assert.assertEquals("Wrong variable type", MetaClassFactory.get(Integer.class), n.getType()); - Assert.assertEquals("Wrong variable value", LiteralFactory.getLiteral(10), n.getValue()); - } - - @Test - public void testDeclareVariableWithStringTypeInference() { - final Context ctx = Context.create(); - final String s = StatementBuilder.create().declareVariable("n", "10").generate(ctx); - - assertEquals("failed to generate variable declaration with =String type inference", - "String n = \"10\";", s); - - final VariableReference n = ctx.getVariable("n"); - assertEquals("Wrong variable name", "n", n.getName()); - Assert.assertEquals("Wrong variable type", MetaClassFactory.get(String.class), n.getType()); - Assert.assertEquals("Wrong variable value", LiteralFactory.getLiteral("10"), n.getValue()); - } - - @Test - public void testDeclareVariableWithImplicitTypeConversion() { - final Context ctx = Context.create(); - final String s = StatementBuilder.create().declareVariable("n", Integer.class, "10").generate(ctx); - - assertEquals("failed to generate variable declaration with implicit type conversion", - "Integer n = 10;", s); - - final VariableReference n = ctx.getVariable("n"); - assertEquals("Wrong variable name", "n", n.getName()); - Assert.assertEquals("Wrong variable type", MetaClassFactory.get(Integer.class), n.getType()); - Assert.assertEquals("Wrong variable value", LiteralFactory.getLiteral(10), n.getValue()); - - try { - StatementBuilder.create().declareVariable("n", Integer.class, "abc").toJavaString(); - fail("Expected InvalidTypeException"); - } - catch (InvalidTypeException ive) { - // expected - assertTrue(ive.getCause() instanceof NumberFormatException); - } - } - - @Test - public void testDeclareVariableWithObjectInitializationWithExactTypeProvided() { - final Context ctx = Context.create(); - final String s = StatementBuilder.create().declareVariable("str", String.class, - ObjectBuilder.newInstanceOf(String.class)).generate(ctx); - - assertEquals("failed to generate variable declaration with object initialization and type provided", - "String str = new String();", s); - - final VariableReference str = ctx.getVariable("str"); - assertEquals("Wrong variable name", "str", str.getName()); - Assert.assertEquals("Wrong variable type", MetaClassFactory.get(String.class), str.getType()); - } - - @Test - public void testDeclareVariableWithObjectInitializationWithStringTypeInference() { - final Context ctx = Context.create(); - final String s = StatementBuilder.create(ctx) - .declareVariable("str", ObjectBuilder.newInstanceOf(String.class)).toJavaString(); - - assertEquals("failed to generate variable declaration with object initialization and string type inference", - "String str = new String();", s); - - final VariableReference str = ctx.getVariable("str"); - assertEquals("Wrong variable name", "str", str.getName()); - Assert.assertEquals("Wrong variable type", MetaClassFactory.get(String.class), str.getType()); - } - - @Test - public void testDeclareVariableWithStatementInitialization() { - final Context ctx = Context.create(); - final String s = Stmt.declareVariable("str", String.class, - Stmt.nestedCall(Stmt.newObject(Integer.class).withParameters(2)).invoke("toString")) - .generate(ctx); - - assertEquals("failed to generate variable declaration with statement initialization", - "String str = new Integer(2).toString();", s); - - final VariableReference str = ctx.getVariable("str"); - assertEquals("Wrong variable name", "str", str.getName()); - Assert.assertEquals("Wrong variable type", MetaClassFactory.get(String.class), str.getType()); - } - - @Test - public void testDeclareFinalVariable() { - final Context ctx = Context.create(); - final String s = StatementBuilder.create(ctx) - .declareVariable(String.class).asFinal().named("str").initializeWith("10").toJavaString(); - - assertEquals("failed to generate final variable declaration", "final String str = \"10\";", s); - - final VariableReference str = ctx.getVariable("str"); - assertEquals("Wrong variable name", "str", str.getName()); - Assert.assertTrue("Variable should be final", ctx.getVariables().get("str").isFinal()); - Assert.assertEquals("Wrong variable type", MetaClassFactory.get(String.class), str.getType()); - } - - @Test - public void testLoadUndefinedVariable() { - try { - StatementBuilder.create().loadVariable("n").toJavaString(); - fail("Expected OutOfScopeException"); - } - catch (OutOfScopeException e) { - // expected - } - } - - @Test - public void testCreateAndInitializeArray() { - final String s = StatementBuilder.create().newArray(String.class).initialize("1", "2").toJavaString(); - assertEquals("Failed to generate 1-dimensional String array", "new String[] { \"1\", \"2\" }", s); - } - - @Test - public void testCreateAndInitializeArrayWithInvalidInitialization() { - try { - StatementBuilder.create().newArray(Annotation.class) - .initialize("1", "2") - .toJavaString(); - fail("Expected InvalidTypeException"); - } - catch (InvalidTypeException oose) { - // expected - } - } - - @Test - public void testCreateAndInitializeArrayWithMissingInitializationAndDimensions() { - try { - StatementBuilder.create().newArray(String.class).toJavaString(); - fail("Expected RuntimeException"); - } - catch (Exception e) { - // expected - assertEquals("Wrong exception details", - "Must provide either dimension expressions or an array initializer", e.getMessage()); - } - } - - @Test - public void testCreateAndInitializeAnnotationArray() { - final Statement annotation1 = ObjectBuilder.newInstanceOf(Annotation.class) - .extend() - .publicOverridesMethod("annotationType") - .append(StatementBuilder.create().load(Inject.class).returnValue()) - .finish() - .finish(); - - final Statement annotation2 = ObjectBuilder.newInstanceOf(Annotation.class) - .extend() - .publicOverridesMethod("annotationType") - .append(StatementBuilder.create().load(PostConstruct.class).returnValue()) - .finish() - .finish(); - - final String s = StatementBuilder.create().newArray(Annotation.class) - .initialize(annotation1, annotation2) - .toJavaString(); - - assertEquals("failed to generate Annotation array", - "new java.lang.annotation.Annotation[] { " + - "new java.lang.annotation.Annotation() {\n" + - " public Class annotationType() {\n" + - " return javax.inject.Inject.class;\n" + - " }\n" + - "}" + - ", new java.lang.annotation.Annotation() {\n" + - " public Class annotationType() {\n" + - " return javax.annotation.PostConstruct.class;\n" + - " }\n" + - " }\n" + - "}", s); - } - - @Test - @SuppressWarnings(value = { "all" }) - public void testCreateAndInitializeTwoDimensionalArray() { - final String s = StatementBuilder.create().newArray(Integer.class) - .initialize(new Integer[][] { { 1, 2 }, { 3, 4 } }) - .toJavaString(); - - assertEquals("Failed to generate two dimensional array", "new Integer[][] { { 1, 2 }, { 3, 4 } }", s); - } - - @Test - @SuppressWarnings(value = { "all" }) - public void testCreateAndInitializeTwoDimensionalArrayWithSingleValue() { - final String s = StatementBuilder.create().newArray(Integer.class) - .initialize(new Object[][] { { 1, 2 } }) - .toJavaString(); - - assertEquals("Failed to generate two dimensional array", "new Integer[][] { { 1, 2 } }", s); - } - - @Test - @SuppressWarnings(value = { "all" }) - public void testCreateAndInitializeTwoDimensionalObjectArrayWithIntegers() { - final String s = StatementBuilder.create().newArray(Object.class) - .initialize(new Object[][] { { 1, 2 } }) - .toJavaString(); - - assertEquals("Failed to generate two dimensional array", "new Object[][] { { 1, 2 } }", s); - } - - @Test - @SuppressWarnings(value = { "all" }) - public void testCreateAndInitializeTwoDimensionalArrayWithStatements() { - final String s = StatementBuilder.create().newArray(String.class) - .initialize(new Statement[][] { - { StatementBuilder.create().invokeStatic(Integer.class, "toString", 1), - StatementBuilder.create().invokeStatic(Integer.class, "toString", 2) }, - { StatementBuilder.create().invokeStatic(Integer.class, "toString", 3), - StatementBuilder.create().invokeStatic(Integer.class, "toString", 4) } }) - .toJavaString(); - - assertEquals("Failed to generate two dimensional array using statements", - "new String[][] { { Integer.toString(1), Integer.toString(2) }, " + - "{ Integer.toString(3), Integer.toString(4) } }", s); - } - - @Test - @SuppressWarnings(value = { "all" }) - public void testCreateAndInitializeTwoDimensionalArrayWithStatementsAndLiterals() { - final String s = StatementBuilder.create().newArray(String.class) - .initialize(new Object[][] { - { StatementBuilder.create().invokeStatic(Integer.class, "toString", 1), "2" }, - { StatementBuilder.create().invokeStatic(Integer.class, "toString", 3), "4" } }) - .toJavaString(); - - assertEquals("Failed to generate two dimensional array using statements and objects", - "new String[][] { { Integer.toString(1), \"2\" }," + - " { Integer.toString(3), \"4\" } }", s); - } - - @Test - @SuppressWarnings(value = { "all" }) - public void testCreateAndInitializeThreeDimensionalArray() { - final String s = StatementBuilder.create().newArray(String.class) - .initialize(new String[][][] { { { "1", "2" }, { "a", "b" } }, { { "3", "4" }, { "b", "c" } } }) - .toJavaString(); - - assertEquals("Failed to generate three dimensional array", - "new String[][][] { { { \"1\", \"2\" }, { \"a\", \"b\" } }, { { \"3\", \"4\" }, { \"b\", \"c\" } } }", s); - } - - @Test - public void testAssignArrayValue() { - final String s = StatementBuilder.create() - .declareVariable("twoDimArray", String[][].class) - .loadVariable("twoDimArray", 1, 2) - .assignValue("test") - .toJavaString(); - - assertEquals("Failed to generate array assignment", "twoDimArray[1][2] = \"test\";", s); - } - - @Test - public void testAssignArrayValueWithPreIncrementAssignment() { - final String s = StatementBuilder.create() - .declareVariable("twoDimArray", String[][].class) - .loadVariable("twoDimArray", 1, 2) - .assignValue(AssignmentOperator.PreIncrementAssign, "test") - .toJavaString(); - - assertEquals("Failed to generate array assignment", "twoDimArray[1][2] += \"test\";", s); - } - - @Test - public void testAssignArrayValueWithVariableIndexes() { - final String s = StatementBuilder.create() - .declareVariable("twoDimArray", String[][].class) - .declareVariable("i", int.class) - .declareVariable("j", int.class) - .loadVariable("twoDimArray", Variable.get("i"), Variable.get("j")) - .assignValue("test") - .toJavaString(); - - assertEquals("Failed to generate array assignment", "twoDimArray[i][j] = \"test\";", s); - } - - @Test - public void testAssignArrayValueWithInvalidArray() { - try { - StatementBuilder.create() - .declareVariable("twoDimArray", String.class) - .loadVariable("twoDimArray", 1, 2) - .assignValue("test") - .toJavaString(); - - fail("Expected InvalidTypeExcpetion"); - } - catch (InvalidTypeException e) { - // Expected, variable is not an array. - } - } - - @Test - public void testAssignArrayValueWithInvalidIndexType() { - try { - StatementBuilder.create() - .declareVariable("twoDimArray", String[][].class) - .declareVariable("i", float.class) - .declareVariable("j", float.class) - .loadVariable("twoDimArray", Variable.get("i"), Variable.get("j")) - .assignValue("test") - .toJavaString(); - fail("Expected InvalidTypeExcpetion"); - } - catch (InvalidTypeException e) { - // Expected, indexes are no integers - } - } - - @Test - public void testObjectCreationWithLiteralParameter() { - final String s = StatementBuilder.create().newObject(String.class).withParameters("original").toJavaString(); - assertEquals("failed to generate new object with parameters", "new String(\"original\")", s); - } - - @Test - public void testObjectCreationWithVariableParameter() { - final String s = StatementBuilder.create() - .declareVariable("original", String.class) - .newObject(String.class).withParameters(Variable.get("original")).toJavaString(); - assertEquals("failed to generate new object with parameters", "new String(original)", s); - } - - @Test - public void testObjectCreationWithParameterizedType() { - final String s = StatementBuilder.create().newObject(new TypeLiteral>() { - }).toJavaString(); - assertEquals("failed to generate new object with parameterized type", "new java.util.ArrayList()", s); - } - - @Test - public void testObjectCreationWithAutoImportedParameterizedType() { - final Context c = Context.create().autoImport(); - final String s = StatementBuilder.create(c).newObject(new TypeLiteral>() { - }).toJavaString(); - assertEquals("failed to generate new object with parameterized type", "new ArrayList()", s); - } - - @Test - public void testObjectCreationWithParameterizedTypeAndClassImport() { - final Context c = Context.create().addImport(MetaClassFactory.get(ArrayList.class)); - final String s = StatementBuilder.create(c).newObject(new TypeLiteral>() { - }).toJavaString(); - assertEquals("failed to generate new object with parameterized type", "new ArrayList()", s); - } - - @Test - public void testObjectCreationWithFullyQualifiedParameterizedTypeAndClassImport() { - final Context c = Context.create().addImport(MetaClassFactory.get(ArrayList.class)); - final String s = StatementBuilder.create(c).newObject(new TypeLiteral>() { - }).toJavaString(); - assertEquals("failed to generate new object with parameterized type", "new ArrayList()", s); - } - - @Test - public void testObjectCreationWithNestedParameterizedTypeAndClassImports() { - final Context c = Context.create() - .addImport(MetaClassFactory.get(ArrayList.class)) - .addImport(MetaClassFactory.get(HashMap.class)); - - final String s = StatementBuilder.create(c) - .newObject(new TypeLiteral>>>() { - }).toJavaString(); - assertEquals("failed to generate new object with parameterized type", - "new ArrayList>>()", s); - } - - @Test - public void testObjectCreationOfUninstantiableType() { - try { - Stmt.newObject(List.class).toJavaString(); - fail("Expected InvalidTypeExcpetion"); - } - catch (InvalidTypeException e) { - // Expected, List is not instantiable - } - } - - @Test - public void testThrowExceptionUsingNewInstance() { - final Context c = Context.create().autoImport(); - final String s = StatementBuilder.create(c).throw_(InvalidTypeException.class).toJavaString(); - assertEquals("failed to generate throw statement using a new instance", - "throw new InvalidTypeException()", s); - } - - @Test - public void testThrowExceptionUsingNewInstanceWithParameters() { - final Context c = Context.create().autoImport(); - final String s = StatementBuilder.create(c).throw_(InvalidTypeException.class, "message").toJavaString(); - assertEquals("failed to generate throw statement using a new instance", - "throw new InvalidTypeException(\"message\")", s); - } - - @Test - public void testThrowExceptionUsingVariable() { - final String s = StatementBuilder.create().declareVariable("t", Throwable.class).throw_("t").toJavaString(); - assertEquals("failed to generate throw statement using a variable", "throw t", s); - } - - @Test - public void testThrowExceptionUsingInvalidVariable() { - try { - StatementBuilder.create() - .declareVariable("t", Integer.class) - .throw_("t") - .toJavaString(); - fail("expected InvalidTypeException"); - } - catch (InvalidTypeException e) { - // expected - } - } - - @Test - public void testThrowExceptionUsingUndefinedVariable() { - try { - StatementBuilder.create() - .throw_("t") - .toJavaString(); - fail("expected OutOfScopeException"); - } - catch (OutOfScopeException e) { - // expected - } - } - - @Test - public void testNestedCall() { - final String s = StatementBuilder.create() - .nestedCall( - StatementBuilder.create().declareVariable("n", Integer.class).loadVariable("n").invoke("toString")) - .invoke("getBytes") - .toJavaString(); - - assertEquals("failed to generate nested call", "n.toString().getBytes()", s); - } - - @Test - public void testAssignField() { - final String s = Stmt.create(Context.create().autoImport()).nestedCall( - Stmt.newObject(Foo.class)).loadField("bar").loadField("name").assignValue("test").toJavaString(); - - assertEquals("failed to generate nested field assignment", - "new Foo().bar.name = \"test\";", s); - } - - @Test - public void testAssignInvalidField() { - try { - final String s = Stmt.create(Context.create().autoImport()).nestedCall( - Stmt.newObject(Foo.class)) - .loadField("invalid") - .assignValue("test") - .toJavaString(); - - fail("expected UndefinedFieldException"); - } - catch (UndefinedFieldException e) { - // expected - } - } - - @Test - public void testCastDown() { - final Statement stmt = Cast.to(String.class, Stmt.declareVariable("obj", Object.class).loadVariable("obj")); - assertEquals("failed to generate cast", "(String) obj", stmt.generate(Context.create())); - } - - @Test - public void testCastUp() { - final Statement stmt = Cast.to(Object.class, Stmt.declareVariable("str", String.class).loadVariable("str")); - assertEquals("created a redundant cast", "str", stmt.generate(Context.create())); - } - - - @Test - public void testCastWithVariableGetAPI() { - final Context ctx = Context.create(); - ctx.addVariable(Variable.create("str", String.class)); - - final Statement stmt = Cast.to(Object.class, Variable.get("str")); - assertEquals("created a redundant cast", "str", stmt.generate(ctx)); - } - - - @Test - public void testInvalidCast() { - try { - final Statement stmt = Cast.to(Integer.class, Stmt.declareVariable("str", String.class).loadVariable("str")); - stmt.generate(Context.create()); - fail("expected InvalidTypeException"); - } - catch (InvalidTypeException e) { - // expected - assertEquals("Wrong exception message", "java.lang.String cannot be cast to java.lang.Integer", e.getMessage()); - } - } - - @Test - public void testReturnVoid() { - final Context ctx = Context.create(); - ctx.addVariable(Variable.create("foo", Object.class)); - - final Statement stmt = Stmt.if_(Bool.isNull(Refs.get("foo"))) - .append(Stmt.returnVoid()).finish(); - - assertEquals("failed to generate return statement", "if (foo == null) {\n" + - " return;\n" + - "}", stmt.generate(ctx)); - } - - @Test - public void testTypeInferenceWorksPropertyForParameterizedMethodTypes() { - final String s = - Stmt.loadStatic(BeanWithTypeParmedMeths.class, "INSTANCE") - .invoke("setFooBarMap", Stmt.loadStatic(BeanWithTypeParmedMeths.class, "INSTANCE").invoke("getFooBarMap")) - .toJavaString(); - - assertEquals("org.jboss.errai.codegen.test.model.BeanWithTypeParmedMeths.INSTANCE" + - ".setFooBarMap(org.jboss.errai.codegen.test.model.BeanWithTypeParmedMeths.INSTANCE.getFooBarMap())", - s); - } - - @Test - public void testBitwiseOrExpression() { - final String generate = Bitwise.or(Stmt.load(1), Stmt.load(2), Stmt.load(3)).generate(Context.create()); - - assertEquals("1 | 2 | 3", generate); - } - - @Test - public void testBitwiseAndExpression() { - final String generate = Bitwise.and(Stmt.load(1), Stmt.load(2), Stmt.load(3)).generate(Context.create()); - - assertEquals("1 & 2 & 3", generate); - } - - @Test - public void testMixedBitwise() { - final String generate = Bitwise.or(Stmt.load(1), Stmt.load(2), - Expr.qualify(Bitwise.and(Stmt.load(10), Stmt.load(20)))).generate(Context.create()); - - assertEquals("1 | 2 | (10 & 20)", generate); - } - - @Test - public void testPassBitwiseToMethodParameter() { - final Statement bitwiseStatement = Bitwise.or(Stmt.load(1), Stmt.load(2), - Expr.qualify(Bitwise.and(Stmt.load(10), Stmt.load(20)))); - - final String generate = Stmt.newObject(Integer.class).withParameters(bitwiseStatement).generate(Context.create()); - - assertEquals("new Integer(1 | 2 | (10 & 20))", generate); - } - - @Test - public void testEnumReference() { - final ContextualStatementBuilder statementBuilder = Stmt.loadStatic(TEnum.class, "FIRST"); - - assertEquals(TEnum.class.getName() + ".FIRST", statementBuilder.generate(Context.create())); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/SwitchBlockBuilderTest.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/SwitchBlockBuilderTest.java deleted file mode 100644 index 444c1cc2ba8..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/SwitchBlockBuilderTest.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test; - -import org.jboss.errai.codegen.Context; -import org.jboss.errai.codegen.builder.impl.StatementBuilder; -import org.jboss.errai.codegen.exception.InvalidTypeException; -import org.jboss.errai.codegen.util.Stmt; -import org.junit.Test; - -import static org.jboss.errai.codegen.test.SwitchBlockBuilderTestResult.SWITCH_BLOCK_CHAINED_INVOCATION; -import static org.jboss.errai.codegen.test.SwitchBlockBuilderTestResult.SWITCH_BLOCK_CHAR_CHAINED; -import static org.jboss.errai.codegen.test.SwitchBlockBuilderTestResult.SWITCH_BLOCK_EMPTY; -import static org.jboss.errai.codegen.test.SwitchBlockBuilderTestResult.SWITCH_BLOCK_ENUM; -import static org.jboss.errai.codegen.test.SwitchBlockBuilderTestResult.SWITCH_BLOCK_INT; -import static org.jboss.errai.codegen.test.SwitchBlockBuilderTestResult.SWITCH_BLOCK_INTEGER_NO_DEFAULT; -import static org.jboss.errai.codegen.test.SwitchBlockBuilderTestResult.SWITCH_BLOCK_INT_FALLTHROUGH; -import static org.junit.Assert.fail; - -/** - * Tests the generation of switch blocks using the {@link StatementBuilder} API. - * - * @author Christian Sadilek - */ -public class SwitchBlockBuilderTest extends AbstractCodegenTest { - public enum TestEnum { - A, B; - } - - @Test - public void testSwitchBlockWithInvalidStatement() { - try { - StatementBuilder.create() - .switch_(Stmt.loadStatic(System.class, "out")) - .toJavaString(); - fail("expected InvalidTypeException"); - } - catch (InvalidTypeException e) { - // expected - } - } - - @Test - public void testSwitchBlockWithInvalidCaseValueUsingEnumForInt() { - try { - Context c = Context.create().addVariable("n", int.class); - StatementBuilder.create(c) - .switch_(c.getVariable("n")) - .case_(TestEnum.A) - .finish() - .toJavaString(); - fail("expected InvalidTypeException"); - } - catch (InvalidTypeException e) { - // expected - } - } - - @Test - public void testSwitchBlockWithInvalidCaseValueUsingIntForEnum() { - try { - Context c = Context.create().addVariable("t", TestEnum.class); - StatementBuilder.create(c) - .switch_(Stmt.loadVariable("t")) - .case_(1) - .finish() - .toJavaString(); - fail("expected InvalidTypeException"); - } - catch (InvalidTypeException e) { - // expected - } - } - - @Test - public void testSwitchBlockOnIntEmpty() { - String s = StatementBuilder.create() - .declareVariable("n", int.class) - .switch_(Stmt.loadVariable("n")) - .toJavaString(); - - assertEquals("Failed to generate empty switch block", SWITCH_BLOCK_EMPTY, s); - } - - @Test - public void testSwitchBlockOnInt() { - String s = StatementBuilder.create() - .declareVariable("n", int.class) - .switch_(Stmt.loadVariable("n")) - .case_(0) - .append(Stmt.loadStatic(System.class, "out").invoke("println", "0")) - .append(Stmt.loadStatic(System.class, "out").invoke("println", "break")) - .append(Stmt.break_()) - .finish() - .case_(1) - .append(Stmt.break_()) - .finish() - .default_() - .append(Stmt.break_()) - .finish() - .toJavaString(); - - assertEquals("Failed to generate int switch block", SWITCH_BLOCK_INT, s); - } - - @Test - public void testSwitchBlockOnEnum() { - Context c = Context.create().autoImport(); - String s = StatementBuilder.create(c) - .declareVariable("t", TestEnum.class) - .switch_(Stmt.loadVariable("t")) - .case_(TestEnum.A) - .append(Stmt.loadStatic(System.class, "out").invoke("println", "A")) - .append(Stmt.loadStatic(System.class, "out").invoke("println", "break")) - .append(Stmt.break_()) - .finish() - .case_(TestEnum.B) - .append(Stmt.break_()) - .finish() - .default_() - .append(Stmt.break_()) - .finish() - .toJavaString(); - - assertEquals("Failed to generate enum switch block", SWITCH_BLOCK_ENUM, s); - } - - @Test - public void testSwitchBlockWithoutDefaultBlock() { - String s = StatementBuilder.create() - .declareVariable("n", Integer.class) - .switch_(Stmt.loadVariable("n")) - .case_(0) - .append(Stmt.loadStatic(System.class, "out").invoke("println", "0")) - .append(Stmt.loadStatic(System.class, "out").invoke("println", "break")) - .append(Stmt.break_()) - .finish() - .case_(1) - .append(Stmt.break_()) - .finish() - .toJavaString(); - - assertEquals("Failed to generate Integer switch block without default", SWITCH_BLOCK_INTEGER_NO_DEFAULT, s); - } - - @Test - public void testSwitchBlockWithFallThrough() { - String s = StatementBuilder.create() - .declareVariable("n", int.class) - .switch_(Stmt.loadVariable("n")) - .case_(0) - .finish() - .case_(1) - .append(Stmt.loadStatic(System.class, "out").invoke("println", "1")) - .append(Stmt.loadStatic(System.class, "out").invoke("println", "break")) - .append(Stmt.break_()) - .finish() - .toJavaString(); - - assertEquals("Failed to generate int switch block with fallthrough", SWITCH_BLOCK_INT_FALLTHROUGH, s); - } - - @Test - public void testSwitchBlockChained() { - String s = StatementBuilder.create() - .declareVariable("n", int.class) - .loadVariable("n") - .switch_() - .case_(0) - .append(Stmt.loadStatic(System.class, "out").invoke("println", "0")) - .append(Stmt.loadStatic(System.class, "out").invoke("println", "break")) - .append(Stmt.break_()) - .finish() - .case_(1) - .append(Stmt.break_()) - .finish() - .default_() - .append(Stmt.break_()) - .finish() - .toJavaString(); - - assertEquals("Failed to generate chained switch block", SWITCH_BLOCK_INT, s); - } - - @Test - public void testSwitchBlockChainedOnChar() { - String s = StatementBuilder.create() - .declareVariable("c", char.class) - .loadVariable("c") - .switch_() - .case_('a') - .append(Stmt.loadStatic(System.class, "out").invoke("println", "a")) - .append(Stmt.break_()) - .finish() - .case_('b') - .append(Stmt.break_()) - .finish() - .default_() - .append(Stmt.break_()) - .finish() - .toJavaString(); - - assertEquals("Failed to generate char switch block", SWITCH_BLOCK_CHAR_CHAINED, s); - } - - @Test - public void testSwitchBlockChainedOnInvocation() { - String s = StatementBuilder.create() - .declareVariable("str", String.class) - .loadVariable("str") - .invoke("length") - .switch_() - .case_(0) - .append(Stmt.loadStatic(System.class, "out").invoke("println", "0")) - .append(Stmt.loadStatic(System.class, "out").invoke("println", "break")) - .append(Stmt.break_()) - .finish() - .case_(1) - .append(Stmt.break_()) - .finish() - .default_() - .append(Stmt.break_()) - .finish() - .toJavaString(); - - assertEquals("Failed to generate switch block chained on invocation", SWITCH_BLOCK_CHAINED_INVOCATION, s); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/SwitchBlockBuilderTestResult.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/SwitchBlockBuilderTestResult.java deleted file mode 100644 index 6670e369488..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/SwitchBlockBuilderTestResult.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test; - -/** - * @author Christian Sadilek - */ -public interface SwitchBlockBuilderTestResult { - - public static final String SWITCH_BLOCK_EMPTY = - " switch (n) {\n" + - " } "; - - public static final String SWITCH_BLOCK_INT = - " switch (n) {\n" + - " case 0: System.out.println(\"0\"); System.out.println(\"break\"); break;" + - " case 1: break;" + - " default: break;" + - " } "; - - public static final String SWITCH_BLOCK_INTEGER_NO_DEFAULT = - " switch (n) {\n" + - " case 0: System.out.println(\"0\"); System.out.println(\"break\"); break;" + - " case 1: break;" + - " } "; - - public static final String SWITCH_BLOCK_ENUM = - " switch (t) {\n" + - " case A: System.out.println(\"A\"); System.out.println(\"break\"); break;" + - " case B: break;" + - " default: break;" + - " } "; - - public static final String SWITCH_BLOCK_INT_FALLTHROUGH = - " switch (n) {\n" + - " case 0:" + - " case 1: System.out.println(\"1\"); System.out.println(\"break\"); break;" + - " } "; - - public static final String SWITCH_BLOCK_CHAINED_INVOCATION = - " switch (str.length()) {\n" + - " case 0: System.out.println(\"0\"); System.out.println(\"break\"); break;" + - " case 1: break;" + - " default: break;" + - " } "; - - public static final String SWITCH_BLOCK_CHAR_CHAINED = - " switch (c) {\n" + - " case 'a': System.out.println(\"a\"); break;" + - " case 'b': break;" + - " default: break;" + - " } "; -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/TryBlockBuilderTest.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/TryBlockBuilderTest.java deleted file mode 100644 index 0f840aad035..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/TryBlockBuilderTest.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test; - -import org.jboss.errai.codegen.Variable; -import org.jboss.errai.codegen.builder.impl.StatementBuilder; -import org.jboss.errai.codegen.util.Stmt; -import org.junit.Test; - -import static org.jboss.errai.codegen.test.TryBlockBuilderTestResult.EMPTY_TRY_CATCH_BLOCK; -import static org.jboss.errai.codegen.test.TryBlockBuilderTestResult.EMPTY_TRY_CATCH_FINALLY_BLOCK; -import static org.jboss.errai.codegen.test.TryBlockBuilderTestResult.EMPTY_TRY_FINALLY_BLOCK; -import static org.jboss.errai.codegen.test.TryBlockBuilderTestResult.EMPTY_TRY_MULTIPLE_CATCH_FINALLY_BLOCK; -import static org.jboss.errai.codegen.test.TryBlockBuilderTestResult.TRY_CATCH_FINALLY_BLOCK; - -/** - * Tests the generation of try/catch/finally blocks using the {@link StatementBuilder} API. - * - * @author Christian Sadilek - */ -public class TryBlockBuilderTest extends AbstractCodegenTest { - - @Test - public void testEmptyTryBlock() { - String s = StatementBuilder.create() - .try_() - .finish() - .toJavaString(); - - assertEquals("Failed to generate empty try catch block", EMPTY_TRY_FINALLY_BLOCK, s); - } - - @Test - public void testTryFinallyBlock() { - String s = StatementBuilder.create() - .try_() - .finish() - .finally_() - .finish() - .toJavaString(); - - assertEquals("Failed to generate empty try finally block", EMPTY_TRY_FINALLY_BLOCK, s); - } - - @Test - public void testTryCatchBlock() { - String s = StatementBuilder.create() - .try_() - .finish() - .catch_(Throwable.class, "t") - .finish() - .toJavaString(); - - assertEquals("Failed to generate empty try catch block", EMPTY_TRY_CATCH_BLOCK, s); - } - - @Test - public void testTryCatchFinallyBlockEmpty() { - String s = StatementBuilder.create() - .try_() - .finish() - .catch_(Throwable.class, "t") - .finish() - .finally_() - .finish() - .toJavaString(); - - assertEquals("Failed to generate empty try catch finally block", EMPTY_TRY_CATCH_FINALLY_BLOCK, s); - } - - @Test - public void testTryMultipleCatchFinallyBlock() { - String s = StatementBuilder.create() - .try_() - .finish() - .catch_(Exception.class, "e") - .finish() - .catch_(Throwable.class, "t") - .finish() - .finally_() - .finish() - .toJavaString(); - - assertEquals("Failed to generate empty try catch finally block", EMPTY_TRY_MULTIPLE_CATCH_FINALLY_BLOCK, s); - } - - @Test - public void testTryCatchFinallyBlock() { - String s = StatementBuilder.create() - .try_() - .append(Stmt.throw_(Exception.class)) - .finish() - .catch_(Exception.class, "e") - .append(Stmt.throw_(RuntimeException.class, Variable.get("e"))) - .finish() - .finally_() - .append(Stmt.load(0).returnValue()) - .finish() - .toJavaString(); - - assertEquals("Failed to generate try catch finally block", TRY_CATCH_FINALLY_BLOCK, s); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/TryBlockBuilderTestResult.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/TryBlockBuilderTestResult.java deleted file mode 100644 index ecfdb12809f..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/TryBlockBuilderTestResult.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test; - -/** - * @author Christian Sadilek - */ -public interface TryBlockBuilderTestResult { - - public static final String EMPTY_TRY_FINALLY_BLOCK = - " try {\n" + - " } " + - " finally {\n" + - " }\n"; - - public static final String EMPTY_TRY_CATCH_BLOCK = - " try {\n" + - " } " + - " catch (Throwable t) {\n" + - " }\n"; - - public static final String EMPTY_TRY_CATCH_FINALLY_BLOCK = - " try {\n" + - " } " + - " catch (Throwable t) {\n" + - " }\n" + - " finally {\n" + - " }\n"; - - public static final String EMPTY_TRY_MULTIPLE_CATCH_FINALLY_BLOCK = - " try {\n" + - " } " + - " catch (Exception e) {\n" + - " }\n" + - " catch (Throwable t) {\n" + - " }\n" + - " finally {\n" + - " }\n"; - - public static final String TRY_CATCH_FINALLY_BLOCK = - " try {\n" + - " throw new Exception();" + - " } " + - " catch (Exception e) {\n" + - " throw new RuntimeException(e);" + - " }\n" + - " finally {\n" + - " return 0;" + - " }\n"; -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/meta/AbstractMetaClassTest.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/meta/AbstractMetaClassTest.java deleted file mode 100644 index a718b6b7883..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/meta/AbstractMetaClassTest.java +++ /dev/null @@ -1,790 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.meta; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import com.google.common.collect.Lists; -import com.google.gwt.core.ext.typeinfo.NotFoundException; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaConstructor; -import org.jboss.errai.codegen.meta.MetaField; -import org.jboss.errai.codegen.meta.MetaMethod; -import org.jboss.errai.codegen.meta.MetaParameterizedType; -import org.jboss.errai.codegen.meta.MetaType; -import org.jboss.errai.codegen.meta.MetaTypeVariable; -import org.jboss.errai.codegen.meta.MetaWildcardType; -import org.jboss.errai.codegen.test.model.ClassWithArrayGenerics; -import org.jboss.errai.codegen.test.model.ClassWithGenericCollections; -import org.jboss.errai.codegen.test.model.ClassWithGenericMethods; -import org.jboss.errai.codegen.test.model.HasManyConstructors; -import org.jboss.errai.codegen.test.model.ObjectWithNested; -import org.jboss.errai.codegen.test.model.ParameterizedClass; -import org.jboss.errai.codegen.test.model.TestInterface; -import org.jboss.errai.codegen.test.model.tree.Child; -import org.jboss.errai.codegen.test.model.tree.Grandparent; -import org.jboss.errai.codegen.test.model.tree.GrandparentInterface; -import org.jboss.errai.codegen.test.model.tree.GrandparentSuperInterface; -import org.jboss.errai.codegen.test.model.tree.IsolatedInterface; -import org.jboss.errai.codegen.test.model.tree.Parent; -import org.jboss.errai.codegen.test.model.tree.ParentInterface; -import org.jboss.errai.codegen.test.model.tree.ParentSuperInterface1; -import org.jboss.errai.codegen.test.model.tree.ParentSuperInterface2; -import org.jboss.errai.codegen.util.GenUtil; -import org.junit.Test; -import org.mvel2.util.NullType; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; - -/** - * Subclassable container for the test cases that guarantee an implementation of - * MetaClass conforms to the general contract. Each implementation of MetaClass - * should have a corresponding subclass of this test. This way, every - * implementation of MetaClass will be subjected to the same set of tests. - * - * @author Christian Sadilek - * @author Jonathan Fuerth - * @author Mike Brock - */ -public abstract class AbstractMetaClassTest { - - /** - * Requests the MetaClass impl from the subclass and checks that it's the - * expected subtype of MetaClass before returning it. - * - * @param javaClass - * @return - */ - private MetaClass getMetaClass(final Class javaClass) { - final MetaClass impl = getMetaClassImpl(javaClass); - assertEquals(getTypeOfMetaClassBeingTested(), impl.getClass()); - return impl; - } - - /** - * Returns a MetaClass object--of the type being tested--that represents {@code javaClass}. - * - * @param javaClass The Java class type being requested. - * @return an instance of the subtype of MetaClass that's being tested. - */ - protected abstract MetaClass getMetaClassImpl(Class javaClass); - - /** - * Returns the type of MetaClass that will be returned from {@link #getMetaClassImpl(Class)}. - */ - protected abstract Class getTypeOfMetaClassBeingTested(); - - @Test - public void testInternalNameForOneDimensionalPrimitiveArray() { - final String internalName = getMetaClass(char[].class).getInternalName(); - assertEquals("Wrong internal name generated for one-dimensional primitive array", - "[C", internalName); - } - - @Test - public void testInternalNameForOneDimensionalObjectArray() { - final String internalName = getMetaClass(String[].class).getInternalName(); - assertEquals("Wrong internal name generated for one-dimensional object array", - "[Ljava/lang/String;", internalName); - } - - @Test - public void testInternalNameForMultiDimensionalPrimitiveArray() { - final String internalName = getMetaClass(char[][].class).getInternalName(); - assertEquals("Wrong internal name generated for multidimensional primitive array", - "[[C", internalName); - } - - @Test - public void testInternalNameForMultiDimensionalObjectArray() { - final String internalName = getMetaClass(String[][].class).getInternalName(); - assertEquals("Wrong internal name generated for multidimensional object array", - "[[Ljava/lang/String;", internalName); - } - - @Test - public void testObjectIsAssignableFromNull() throws Exception { - // This test checks the valid case: - // Object example = null; - - final MetaClass metaObject = getMetaClass(Object.class); - final MetaClass metaNull = getMetaClass(NullType.class); - - assertTrue(metaObject.isAssignableFrom(metaNull)); - } - - @Test - public void testChildIsAssignableFromNull() throws Exception { - // This test checks the valid case: - // Child example = null; - - final MetaClass metaChild = getMetaClass(Child.class); - final MetaClass metaNull = getMetaClass(NullType.class); - - assertTrue(metaChild.isAssignableFrom(metaNull)); - } - - @Test - public void testNullIsAssignableToChild() throws Exception { - // This test checks the valid case: - // Child example = null; - - final MetaClass metaChild = getMetaClass(Child.class); - final MetaClass metaNull = getMetaClass(NullType.class); - - assertTrue(metaNull.isAssignableTo(metaChild)); - } - - @Test - public void testIsAssignableFromComparisonForNested() { - final MetaClass interfaceClass = getMetaClass(TestInterface.class); - final MetaClass metaHolderClass = getMetaClass(ObjectWithNested.class); - - // dig out the nested interface from the holder class and ensure it's what we were looking for - final MetaClass nestedInterface = metaHolderClass.getDeclaredClasses()[0]; - assertEquals("MyNestedInterface", nestedInterface.getName()); - assertEquals(getTypeOfMetaClassBeingTested(), nestedInterface.getClass()); - - assertTrue("MyNestedInterface should be assignable from TestInterface", - interfaceClass.isAssignableFrom(nestedInterface)); - } - - @Test - public void testChildIsAssignableFromChild() { - // This test checks the valid case: - // Child example = new Child(); - - final MetaClass metaChild = getMetaClass(Child.class); - - assertTrue(metaChild.isAssignableFrom(metaChild)); - } - - @Test - public void testChildIsAssignableToChild() { - // This test checks the valid case: - // Child example = new Child(); - - final MetaClass metaChild = getMetaClass(Child.class); - - assertTrue(metaChild.isAssignableTo(metaChild)); - } - - @Test - public void testParentIsAssignableFromChild() { - // This test checks the valid case: - // Parent example = new Child(); - - final MetaClass metaChild = getMetaClass(Child.class); - final MetaClass metaParent = getMetaClass(Parent.class); - - assertTrue(metaParent.isAssignableFrom(metaChild)); - } - - @Test - public void testChildIsNotAssignableFromParent() { - // This test checks the disallowed case: - // Child child = new Parent(); - - final MetaClass metaChild = getMetaClass(Child.class); - final MetaClass metaParent = getMetaClass(Parent.class); - - assertFalse(metaChild.isAssignableFrom(metaParent)); - } - - @Test - public void testGrandParentIsAssignableFromChild() { - // This test checks the valid case: - // Grandparent example = new Child(); - - final MetaClass metaChild = getMetaClass(Child.class); - final MetaClass metaGrandparent = getMetaClass(Grandparent.class); - - assertTrue(metaGrandparent.isAssignableFrom(metaChild)); - } - - @Test - public void testChildIsNotAssignableFromGrandParent() { - // This test checks the disallowed case: - // Child child = new Grandparent(); - - final MetaClass metaChild = getMetaClass(Child.class); - final MetaClass metaGrandparent = getMetaClass(Grandparent.class); - - assertFalse(metaChild.isAssignableFrom(metaGrandparent)); - } - - /** - * This is a regression test for ERRAI-238. - */ - @Test - public void testUncleIsAssignableFromChild() { - // This test checks the valid case: - // ParentInterface example = new Child(); - - final MetaClass metaChild = getMetaClass(Child.class); - final MetaClass metaUncle = getMetaClass(ParentInterface.class); - - assertTrue(metaUncle.isAssignableFrom(metaChild)); - } - - @Test - public void testChildIsNotAssignableFromUncle() { - // This test checks the disallowed case: - // Child child = new ParentInterface() {}; - - final MetaClass metaChild = getMetaClass(Child.class); - final MetaClass metaUncle = getMetaClass(ParentInterface.class); - - assertFalse(metaChild.isAssignableFrom(metaUncle)); - } - - /** - * This is a regression test for ERRAI-238. - */ - @Test - public void testUncleInLawIsAssignableFromChild() { - // This test checks the valid case: - // ParentSuperInterface1 example = new Child(); - - final MetaClass metaChild = getMetaClass(Child.class); - final MetaClass metaUncleInLaw = getMetaClass(ParentSuperInterface1.class); - - assertTrue(metaUncleInLaw.isAssignableFrom(metaChild)); - } - - @Test - public void testChildIsNotAssignableFromUncleInLaw() { - // This test checks the disallowed case: - // Child child = new ParentSuperInterface1() {}; - - final MetaClass metaChild = getMetaClass(Child.class); - final MetaClass metaUncleInLaw = getMetaClass(ParentSuperInterface1.class); - - assertFalse(metaChild.isAssignableFrom(metaUncleInLaw)); - } - - /** - * This is a regression test for ERRAI-238. - */ - @Test - public void testUncleInLaw2IsAssignableFromChild() { - // This test checks the valid case: - // ParentSuperInterface2 example = new Child(); - - final MetaClass metaChild = getMetaClass(Child.class); - final MetaClass metaUncleInLaw = getMetaClass(ParentSuperInterface2.class); - - assertTrue(metaUncleInLaw.isAssignableFrom(metaChild)); - } - - @Test - public void testChildIsNotAssignableFromUncleInLaw2() { - // This test checks the disallowed case: - // Child child = new ParentSuperInterface2() {}; - - final MetaClass metaChild = getMetaClass(Child.class); - final MetaClass metaUncleInLaw = getMetaClass(ParentSuperInterface2.class); - - assertFalse(metaChild.isAssignableFrom(metaUncleInLaw)); - } - - /** - * This is a regression test for ERRAI-238. - */ - @Test - public void testGreatUncleIsAssignableFromChild() { - // This test checks the valid case: - // GrandparentInterface example = new Child(); - - final MetaClass metaChild = getMetaClass(Child.class); - final MetaClass metaGreatUncle = getMetaClass(GrandparentInterface.class); - - assertTrue(metaGreatUncle.isAssignableFrom(metaChild)); - } - - @Test - public void testChildIsNotAssignableFromGreatUncle() { - // This test checks the disallowed case: - // Child child = new GrandparentInterface() {}; - - final MetaClass metaChild = getMetaClass(Child.class); - final MetaClass metaGreatUncle = getMetaClass(GrandparentInterface.class); - - assertFalse(metaChild.isAssignableFrom(metaGreatUncle)); - } - - /** - * This is a regression test for ERRAI-238. - */ - @Test - public void testGreatUncleInLawIsAssignableFromChild() { - // This test checks the valid case: - //GrandparentSuperInterface example = new Child(); - - final MetaClass metaChild = getMetaClass(Child.class); - final MetaClass metaGreatUncleInLaw = getMetaClass(GrandparentSuperInterface.class); - - assertTrue(metaGreatUncleInLaw.isAssignableFrom(metaChild)); - } - - @Test - public void testChildIsNotAssignableFromGreatUncleInLaw() { - // This test checks the disallowed case: - // Child child = new GrandparentSuperInterface() {}; - - final MetaClass metaChild = getMetaClass(Child.class); - final MetaClass metaGreatUncleInLaw = getMetaClass(GrandparentSuperInterface.class); - - assertFalse(metaChild.isAssignableFrom(metaGreatUncleInLaw)); - } - - @Test - public void testObjectIsAssignableFromChild() { - // This test checks the valid case: - //Object example = new Child(); - - final MetaClass metaChild = getMetaClass(Child.class); - final MetaClass metaObject = getMetaClass(Object.class); - - assertTrue(metaObject.isAssignableFrom(metaChild)); - } - - @Test - public void testChildIsNotAssignableFromObject() { - // This test checks the disallowed case: - // Child child = new Object(); - - final MetaClass metaChild = getMetaClass(Child.class); - final MetaClass metaObject = getMetaClass(Object.class); - - assertFalse(metaChild.isAssignableFrom(metaObject)); - } - - @Test - public void testObjectIsAssignableFromIsolatedInterface() { - // This test checks the valid case: - // Object example = new IsolatedInterface() {}; - - final MetaClass metaInterface = getMetaClass(IsolatedInterface.class); - final MetaClass metaObject = getMetaClass(Object.class); - - assertTrue(metaObject.isAssignableFrom(metaInterface)); - } - - @Test - public void testIsolatedInterfaceIsNotAssignableFromObject() { - // This test checks the disallowed case: - // IsolatedInterface ii = new Object(); - - final MetaClass metaInterface = getMetaClass(IsolatedInterface.class); - final MetaClass metaObject = getMetaClass(Object.class); - - assertFalse(metaInterface.isAssignableFrom(metaObject)); - } - - @Test - public void testUncleIsAssignableToChild() { - // This test checks the allowed case: - // ParentInterface pi = new Child(); - - final MetaClass metaChild = getMetaClass(Child.class); - final MetaClass metaUncle = getMetaClass(ParentInterface.class); - - assertTrue(metaChild.isAssignableTo(metaUncle)); - } - - @Test - public void testNoDuplicateMethodsInClassHierarchy() throws NotFoundException { - final MetaClass child = getMetaClass(Child.class); - - final List foundMethods = new ArrayList<>(); - for (final MetaMethod m : child.getMethods()) { - if (m.getName().equals("interfaceMethodOverriddenMultipleTimes")) { - foundMethods.add(m); - } - } - - assertEquals("Only one copy of the method should have been found", 1, foundMethods.size()); - } - - @Test - public void testSuperClass() throws Exception { - final MetaClass child = getMetaClass(Child.class); - final MetaClass parent = child.getSuperClass(); - - assertEquals(getMetaClass(Parent.class), parent); - } - - @Test - public void testNamingMethods() throws Exception { - final MetaClass child = getMetaClass(Child.class); - - assertEquals(Child.class.getSimpleName(), child.getName()); - assertEquals(Child.class.getName(), child.getFullyQualifiedName()); - assertEquals(Child.class.getName(), child.getCanonicalName()); - assertEquals("L" + Child.class.getName().replace('.', '/') + ";", child.getInternalName()); - } - - @Test - public void testAccessModifiersForPublicTopLevelClass() throws Exception { - final MetaClass child = getMetaClass(Child.class); - - assertTrue(child.isPublic()); - assertFalse(child.isProtected()); - assertFalse(child.isPrivate()); - - assertTrue(child.isDefaultInstantiable()); - } - - // TODO: add private, pkg private, protected methods to Child, Parent, Grandparent, and test getDeclaredMethods() -// System.out.println("--gwt methods--"); -// for (MetaMethod method : Child.class.getName().getDeclaredMethods()) { -// System.out.println(method.toString()); -// } -// assertEquals(new HashSet(Arrays.asList(Child.class.getName().getDeclaredMethods())), -// new HashSet(Arrays.asList(javaMC.getDeclaredMethods()))); - - @Test - public void testGetInterfaces() throws Exception { - final MetaClass grandparent = getMetaClass(Grandparent.class); - assertEquals(1, grandparent.getInterfaces().length); - assertEquals( - Arrays.asList(getMetaClass(GrandparentInterface.class)), - Arrays.asList(grandparent.getInterfaces())); - } - - @Test - public void testFieldWithStringTypeParam() throws Exception { - final MetaClass metaClass = getMetaClass(ClassWithGenericCollections.class); - final MetaField field = metaClass.getDeclaredField("hasStringParam"); - assertNotNull(field); - - assertEquals("Collection", field.getType().getName()); - assertEquals("java.util.Collection", field.getType().getFullyQualifiedName()); - assertEquals("", field.getType().getParameterizedType().toString()); - assertEquals("java.util.Collection", field.getType().getFullyQualifiedNameWithTypeParms()); - assertEquals("java.util.Collection", field.getType().getErased().getFullyQualifiedNameWithTypeParms()); - assertEquals( - Arrays.asList(getMetaClass(String.class)), - Arrays.asList(field.getType().getParameterizedType().getTypeParameters())); - } - - @Test - public void testFieldWithStringBoundedWildcardTypeParam() throws Exception { - final MetaClass metaClass = getMetaClass(ClassWithGenericCollections.class); - final MetaField field = metaClass.getDeclaredField("hasWildcardExtendsStringParam"); - assertNotNull(field); - - assertEquals("Collection", field.getType().getName()); - assertEquals("java.util.Collection", field.getType().getFullyQualifiedName()); - assertEquals("", field.getType().getParameterizedType().toString()); - assertEquals("java.util.Collection", field.getType().getFullyQualifiedNameWithTypeParms()); - assertEquals("java.util.Collection", field.getType().getErased().getFullyQualifiedNameWithTypeParms()); - - assertEquals(1, field.getType().getParameterizedType().getTypeParameters().length); - final MetaWildcardType typeParam = (MetaWildcardType) field.getType().getParameterizedType().getTypeParameters()[0]; - - assertEquals("Should have no lower bound", - Arrays.asList(), - Arrays.asList(typeParam.getLowerBounds())); - - assertEquals("Upper bound should be java.lang.String", - Arrays.asList(getMetaClass(String.class)), - Arrays.asList(typeParam.getUpperBounds())); - } - - @Test - public void testFieldWithUnboundedTypeVarParam() throws Exception { - final MetaClass metaClass = getMetaClass(ClassWithGenericCollections.class); - final MetaField field = metaClass.getDeclaredField("hasUnboundedTypeVarFromClass"); - assertNotNull(field); - - assertEquals("Collection", field.getType().getName()); - assertEquals("java.util.Collection", field.getType().getFullyQualifiedName()); - assertEquals("java.util.Collection", field.getType().getParameterizedType().getName()); - assertEquals("java.util.Collection", field.getType().getFullyQualifiedNameWithTypeParms()); - assertEquals("java.util.Collection", field.getType().getErased().getFullyQualifiedNameWithTypeParms()); - - assertEquals(1, field.getType().getParameterizedType().getTypeParameters().length); - final MetaTypeVariable typeVar = (MetaTypeVariable) field.getType().getParameterizedType().getTypeParameters()[0]; - - assertEquals("T", typeVar.getName()); - assertEquals("Should have no upper bound", - Arrays.asList(getMetaClass(Object.class)), - Arrays.asList(typeVar.getBounds())); - } - - @Test - public void testFieldWithSingleUpperBoundedTypeVarParam() throws Exception { - final MetaClass metaClass = getMetaClass(ClassWithGenericCollections.class); - final MetaMethod field = metaClass.getDeclaredMethod("hasSingleBoundedTypeVarFromSelf", new Class[] {}); - assertNotNull(field); - - final MetaTypeVariable returnType = (MetaTypeVariable) field.getGenericReturnType(); - assertEquals("B", returnType.getName()); - - assertEquals("Should have a single upper bound", - Arrays.asList(getMetaClass(Serializable.class)), - Arrays.asList(returnType.getBounds())); - } - - @Test - public void testFieldWithTwoUpperBoundedTypeVarParam() throws Exception { - final MetaClass metaClass = getMetaClass(ClassWithGenericCollections.class); - final MetaMethod field = metaClass.getDeclaredMethod("hasDoubleBoundedTypeVarFromSelf", new Class[] {}); - assertNotNull(field); - - final MetaTypeVariable returnType = (MetaTypeVariable) field.getGenericReturnType(); - assertEquals("B", returnType.getName()); - - assertEquals("Should have two upper bounds", - Arrays.asList(getMetaClass(Collection.class), getMetaClass(Serializable.class)), - Arrays.asList(returnType.getBounds())); - } - - @Test - public void testEraseNonGenericType() throws Exception { - final MetaClass child = getMetaClass(Child.class); - assertSame(child, child.getErased()); - } - - @Test - public void testEraseParameterizedTopLevelType() throws Exception { - final MetaClass parameterized = getMetaClass(ParameterizedClass.class); - assertEquals("ParameterizedClass", parameterized.getName()); - assertEquals("org.jboss.errai.codegen.test.model.ParameterizedClass", parameterized.getFullyQualifiedName()); - assertNull(parameterized.getParameterizedType()); - - // I think this would be correct, but right now we get the raw type name - //assertEquals("org.jboss.errai.codegen.test.model.ParameterizedClass", parameterized.getFullyQualifiedNameWithTypeParms()); - - assertEquals("org.jboss.errai.codegen.test.model.ParameterizedClass", parameterized.getErased().getFullyQualifiedNameWithTypeParms()); - } - - @Test - public void testMethodObjectReturnType() { - final MetaClass c = getMetaClass(ClassWithGenericMethods.class); - final MetaMethod method = c.getMethod("methodReturningObject", new Class[] {}); - assertEquals("java.lang.Object", method.getReturnType().getFullyQualifiedNameWithTypeParms()); - assertEquals(getTypeOfMetaClassBeingTested(), method.getReturnType().getClass()); - - // the generic return type should be the same: plain old Object - assertEquals(getMetaClass(Object.class), method.getGenericReturnType()); - } - - @Test - public void testMethodReturnTypeWithWildcardParameter() { - final MetaClass c = getMetaClass(ClassWithGenericMethods.class); - final MetaMethod method = c.getMethod("methodReturningUnboundedWildcardCollection", new Class[] {}); - - // TODO (ERRAI-459) decide whether it's correct to have the type param present or not - // then adjust this assertion to strict equality rather than startsWith() - assertTrue(method.getReturnType().getFullyQualifiedNameWithTypeParms().startsWith("java.util.Collection")); - - final MetaType genericReturnType = method.getGenericReturnType(); - assertNotNull(genericReturnType); - assertTrue("Got unexpected return type type " + genericReturnType.getClass(), - genericReturnType instanceof MetaParameterizedType); - final MetaParameterizedType mpReturnType = (MetaParameterizedType) genericReturnType; - assertEquals(1, mpReturnType.getTypeParameters().length); - - // Sole type parameter should be - assertTrue(mpReturnType.getTypeParameters()[0] instanceof MetaWildcardType); - final MetaWildcardType typeParam = (MetaWildcardType) mpReturnType.getTypeParameters()[0]; - assertArrayEquals(new MetaType[] {}, typeParam.getLowerBounds()); - assertArrayEquals(new MetaType[] { getMetaClass(Object.class) }, typeParam.getUpperBounds()); - } - - @Test - public void testMethodReturnTypeWithUpperBoundedWildcardParameter() { - final MetaClass c = getMetaClass(ClassWithGenericMethods.class); - final MetaMethod method = c.getMethod("methodReturningUpperBoundedWildcardCollection", new Class[] {}); - - // TODO (ERRAI-459) decide whether it's correct to have the type param present or not - // then adjust this assertion to strict equality rather than startsWith() - assertTrue(method.getReturnType().getFullyQualifiedNameWithTypeParms().startsWith("java.util.Collection")); - - final MetaType genericReturnType = method.getGenericReturnType(); - assertNotNull(genericReturnType); - assertTrue("Got unexpected return type type " + genericReturnType.getClass(), - genericReturnType instanceof MetaParameterizedType); - final MetaParameterizedType mpReturnType = (MetaParameterizedType) genericReturnType; - assertEquals(1, mpReturnType.getTypeParameters().length); - - // Sole type parameter should be - assertTrue(mpReturnType.getTypeParameters()[0] instanceof MetaWildcardType); - final MetaWildcardType typeParam = (MetaWildcardType) mpReturnType.getTypeParameters()[0]; - assertArrayEquals(new MetaType[] {}, typeParam.getLowerBounds()); - assertArrayEquals(new MetaType[] { getMetaClass(String.class) }, typeParam.getUpperBounds()); - } - - @Test - public void testMethodReturnTypeWithLowerBoundedWildcardParameter() { - final MetaClass c = getMetaClass(ClassWithGenericMethods.class); - final MetaMethod method = c.getMethod("methodReturningLowerBoundedWildcardCollection", new Class[] {}); - - // TODO (ERRAI-459) decide whether it's correct to have the type param present or not - // then adjust this assertion to strict equality rather than startsWith() - assertTrue(method.getReturnType().getFullyQualifiedNameWithTypeParms().startsWith("java.util.Collection")); - - final MetaType genericReturnType = method.getGenericReturnType(); - assertNotNull(genericReturnType); - assertTrue("Got unexpected return type type " + genericReturnType.getClass(), - genericReturnType instanceof MetaParameterizedType); - final MetaParameterizedType mpReturnType = (MetaParameterizedType) genericReturnType; - assertEquals(1, mpReturnType.getTypeParameters().length); - - // Sole type parameter should be - assertTrue(mpReturnType.getTypeParameters()[0] instanceof MetaWildcardType); - final MetaWildcardType typeParam = (MetaWildcardType) mpReturnType.getTypeParameters()[0]; - assertArrayEquals(new MetaType[] { getMetaClass(String.class) }, typeParam.getLowerBounds()); - assertArrayEquals(new MetaType[] { getMetaClass(Object.class)}, typeParam.getUpperBounds()); - } - - @Test - public void testGetMethods() { - final MetaClass c = getMetaClass(Child.class); - final MetaMethod[] methods = c.getMethods(); - - assertNotNull(methods); - - final List methodSignatures = new ArrayList<>(); - for(final MetaMethod m : methods) { - methodSignatures.add(GenUtil.getMethodString(m)); - } - - final List expectedMethods = new ArrayList<>(); - expectedMethods.add("protectedMethod([])"); - expectedMethods.add("interfaceMethodOverriddenMultipleTimes([])"); - expectedMethods.add("packagePrivateMethod([])"); - expectedMethods.add("finalize([])"); - expectedMethods.add("equals([java.lang.Object])"); - expectedMethods.add("toString([])"); - expectedMethods.add("notify([])"); - expectedMethods.add("wait([])"); - expectedMethods.add("clone([])"); - expectedMethods.add("notifyAll([])"); - expectedMethods.add("getClass([])"); - expectedMethods.add("wait([long])"); - expectedMethods.add("hashCode([])"); - expectedMethods.add("wait([long, int])"); - - Collections.sort(expectedMethods); - Collections.sort(methodSignatures); - - - assertEquals(expectedMethods.toString(), methodSignatures.toString()); - } - - @Test - public void testGetFields() { - final List expectedFields = Lists.newLinkedList(); - expectedFields.add(Child.class.getCanonicalName() + "." + "childPublic"); - expectedFields.add(Parent.class.getCanonicalName() + "." + "parentPublic"); - - final ArrayList actualFields = new ArrayList<>(); - for (final MetaField field : getMetaClass(Child.class).getFields()) { - actualFields.add(field.getDeclaringClass().getCanonicalName() + "." + field.getName()); - } - - Collections.sort(expectedFields); - Collections.sort(actualFields); - - assertEquals(expectedFields.toString(), actualFields.toString()); - } - - @Test - public void testGetDeclaredFields() { - final List expectedFields = Lists.newLinkedList(); - expectedFields.add(Child.class.getCanonicalName() + "." + "childPrivate"); - expectedFields.add(Child.class.getCanonicalName() + "." + "childPackage"); - expectedFields.add(Child.class.getCanonicalName() + "." + "childProtected"); - expectedFields.add(Child.class.getCanonicalName() + "." + "childPublic"); - - final ArrayList actualFields = new ArrayList<>(); - for (final MetaField field : getMetaClass(Child.class).getDeclaredFields()) { - actualFields.add(field.getDeclaringClass().getCanonicalName() + "." + field.getName()); - } - - Collections.sort(expectedFields); - Collections.sort(actualFields); - - assertEquals(expectedFields.toString(), actualFields.toString()); - } - - @Test - public void testGetConstructors() throws Exception { - final MetaClass mc = getMetaClass(HasManyConstructors.class); - final MetaConstructor[] ctors = mc.getConstructors(); - assertEquals("Expected only a single visible constructor to be returned.", 1, ctors.length); - } - - @Test - public void testGetConstructorOnlyFindsPublicConstructor() throws Exception { - final MetaClass mc = getMetaClass(HasManyConstructors.class); - assertNotNull(mc.getConstructor(new Class[0])); - assertNull(mc.getConstructor(new Class[] {int.class})); - assertNull(mc.getConstructor(new Class[] {String.class})); - assertNull(mc.getConstructor(new Class[] {double.class})); - } - - @Test - public void testGetDeclaredConstructors() throws Exception { - final MetaClass mc = getMetaClass(HasManyConstructors.class); - final MetaConstructor[] ctors = mc.getDeclaredConstructors(); - assertEquals("Not all constructors were returned.", 4, ctors.length); - } - - @Test - public void testGetDeclaredConstructorFindsAllConstructors() throws Exception { - final MetaClass mc = getMetaClass(HasManyConstructors.class); - assertNotNull(mc.getDeclaredConstructor(new Class[0])); - assertNotNull(mc.getDeclaredConstructor(new Class[] {int.class})); - assertNotNull(mc.getDeclaredConstructor(new Class[] {String.class})); - assertNotNull(mc.getDeclaredConstructor(new Class[] {double.class})); - } - - @Test - public void testHashCodeErrorWithGenericHavingArrayUpperBound() throws Exception { - final MetaClass mc = getMetaClass(ClassWithArrayGenerics.class).getField("field").getType(); - // Precondition - assertNotNull("Failed to find field with type under test.", mc); - assertNotNull("Type should be parameterized", mc.getParameterizedType()); - final MetaClass superClassWithProblematicBound = mc.getSuperClass(); - try { - superClassWithProblematicBound.hashCode(); - } catch (final Throwable t) { - throw new AssertionError("An error occurred.", t); - } - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/meta/build/BuildMetaClassTest.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/meta/build/BuildMetaClassTest.java deleted file mode 100644 index 3606e5cab69..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/meta/build/BuildMetaClassTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.meta.build; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import com.google.common.collect.Lists; -import org.jboss.errai.codegen.builder.ClassStructureBuilder; -import org.jboss.errai.codegen.builder.impl.ClassBuilder; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaField; -import org.jboss.errai.codegen.test.AbstractCodegenTest; -import org.jboss.errai.codegen.test.model.tree.Parent; -import org.junit.Test; - -/** - * Tests for {@link org.jboss.errai.codegen.meta.impl.build.BuildMetaClass}. - * - * Note: - * This unit test is not based on {@link org.jboss.errai.codegen.test.meta.AbstractMetaClassTest} because - * a {@link org.jboss.errai.codegen.meta.impl.build.BuildMetaClass} cannot be created from an existing - * class. - * - * @author Johannes Barop - */ -public class BuildMetaClassTest extends AbstractCodegenTest { - - @Test - public void testGetFields() { - final ClassStructureBuilder classBuilder = ClassBuilder - .define("Child", Parent.class) - .publicScope() - .body() - .privateField("childPrivate", int.class).finish() - .packageField("childPackage", int.class).finish() - .protectedField("childProtected", int.class).finish() - .publicField("childPublic", int.class).finish(); - final MetaClass child = classBuilder.getClassDefinition(); - final ArrayList fields = new ArrayList(); - for (MetaField field : child.getFields()) { - fields.add(field.getDeclaringClass().getCanonicalName() + "." + field.getName()); - } - - final List expectedFields = Lists.newLinkedList(); - expectedFields.add(child.getCanonicalName() + "." + "childPublic"); - expectedFields.add(Parent.class.getCanonicalName() + "." + "parentPublic"); - - Collections.sort(fields); - Collections.sort(expectedFields); - - assertEquals(expectedFields.toString(), fields.toString()); - } - - @Test - public void testGetDeclaredFields() { - final ClassStructureBuilder classBuilder = ClassBuilder - .define("Child", Parent.class) - .publicScope() - .body() - .privateField("childPrivate", int.class).finish() - .packageField("childPackage", int.class).finish() - .protectedField("childProtected", int.class).finish() - .publicField("childPublic", int.class).finish(); - final MetaClass child = classBuilder.getClassDefinition(); - final ArrayList fields = new ArrayList(); - for (MetaField field : child.getDeclaredFields()) { - fields.add(field.getDeclaringClass().getCanonicalName() + "." + field.getName()); - } - - final List expectedFields = Lists.newLinkedList(); - expectedFields.add(child.getCanonicalName() + "." + "childPrivate"); - expectedFields.add(child.getCanonicalName() + "." + "childPackage"); - expectedFields.add(child.getCanonicalName() + "." + "childProtected"); - expectedFields.add(child.getCanonicalName() + "." + "childPublic"); - - Collections.sort(fields); - Collections.sort(expectedFields); - - assertEquals(expectedFields.toString(), fields.toString()); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/meta/java/JavaReflectionMetaClassTest.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/meta/java/JavaReflectionMetaClassTest.java deleted file mode 100644 index b059b2edfa8..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/meta/java/JavaReflectionMetaClassTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.meta.java; - -import org.jboss.errai.codegen.builder.ContextualStatementBuilder; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaMethod; -import org.jboss.errai.codegen.meta.impl.java.JavaReflectionClass; -import org.jboss.errai.codegen.test.meta.AbstractMetaClassTest; -import org.jboss.errai.codegen.test.model.PortableIntegerParameterDefinition; -import org.junit.Test; - -import static org.jboss.errai.codegen.util.Stmt.nestedCall; -import static org.jboss.errai.codegen.util.Stmt.newObject; -import static org.junit.Assert.assertEquals; - -public class JavaReflectionMetaClassTest extends AbstractMetaClassTest { - - @Override - protected MetaClass getMetaClassImpl(Class javaClass) { - return JavaReflectionClass.newInstance(javaClass); - } - - @Override - protected Class getTypeOfMetaClassBeingTested() { - return JavaReflectionClass.class; - } - - /** - * This reproduces a bug found in the JavaReflectionClass. - * PortableIntegerParameterDefinition overrides a method with a generic return - * type (getValue). Class.getDeclaredMethods returns a bridge method with a - * return type of the upper type bound (in this case, Serializable). This - * resulted in JavaReflectionClass.getMethods() returning a MetaMethod for - * bridge method with the wrong return type, leading to seemingly mysterious - * codegen errors. - */ - @Test - public void testMethodReturnTypeIsSpecializedTypeAndNotFromBridgeMethod() throws Exception { - final MetaClass mc = getMetaClassImpl(PortableIntegerParameterDefinition.class); - final MetaMethod method = mc.getBestMatchingMethod("getValue", new MetaClass[0]); - final ContextualStatementBuilder invokeStmt = nestedCall(newObject(mc)).invoke("getValue"); - // Force statement to load return type - invokeStmt.toJavaString(); - final MetaClass stmtReturnType = invokeStmt.getType(); - - final MetaClass expected = getMetaClassImpl(java.lang.Integer.class); - assertEquals(expected, method.getReturnType()); - assertEquals(expected, stmtReturnType); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/Bar.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/Bar.java deleted file mode 100644 index 7404edfb6c8..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/Bar.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -/** - * @author Mike Brock - */ -public abstract class Bar { - protected String name; - - public Bar() { - - } - - public Bar(String name) { - this.name = name; - } - - public void setName(String name) { - - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/Baz.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/Baz.java deleted file mode 100644 index 79b2e74e139..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/Baz.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -/** - * @author Christian Sadilek - */ -public interface Baz { - - public void someMethod(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/BeanWithTypeParmedMeths.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/BeanWithTypeParmedMeths.java deleted file mode 100644 index 998a43d7996..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/BeanWithTypeParmedMeths.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -import java.util.Collections; -import java.util.Map; - -/** - * @author Mike Brock - */ -public class BeanWithTypeParmedMeths { - public static final BeanWithTypeParmedMeths INSTANCE = new BeanWithTypeParmedMeths(); - - public Map getFooBarMap() { - return Collections.emptyMap(); - } - - public void setFooBarMap(Map map) { - // do nothing; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/Bwah.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/Bwah.java deleted file mode 100644 index eb9f095e000..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/Bwah.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -/** - * @author Mike Brock - */ -public class Bwah { - public static T create(Class classLiteral) { - return null; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/ClassWithArrayGenerics.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/ClassWithArrayGenerics.java deleted file mode 100644 index bf735da46d2..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/ClassWithArrayGenerics.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -/** - * - * @author Max Barkley - */ -public class ClassWithArrayGenerics { - - public GenericArraySubclass field; - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/ClassWithGenericCollections.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/ClassWithGenericCollections.java deleted file mode 100644 index 1cba21b0d3b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/ClassWithGenericCollections.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -import java.io.Serializable; -import java.util.Collection; - -/** - * A class with fields of various generic types, for testing the MetaClass implementations. - * - * @author Jonathan Fuerth - */ -public class ClassWithGenericCollections { - Collection hasStringParam; - Collection hasWildcardExtendsStringParam; - Collection hasUnboundedTypeVarFromClass; - - B hasSingleBoundedTypeVarFromSelf() { - return null; - } - - B hasDoubleBoundedTypeVarFromSelf() { - return null; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/ClassWithGenericMethods.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/ClassWithGenericMethods.java deleted file mode 100644 index fa135490ba5..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/ClassWithGenericMethods.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -import java.util.Collection; - -/** - * A class with methods returning and accepting parameters of various generic - * types, for testing the MetaClass implementations. - * - * @author Jonathan Fuerth - */ -public class ClassWithGenericMethods { - - public Object methodReturningObject() { - return null; - } - - public Collection methodReturningUnboundedWildcardCollection() { - return null; - } - - public Collection methodReturningUpperBoundedWildcardCollection() { - return null; - } - - public Collection methodReturningLowerBoundedWildcardCollection() { - return null; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/FakeBean.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/FakeBean.java deleted file mode 100644 index 91e42cb7aff..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/FakeBean.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -import java.math.BigDecimal; -import java.math.BigInteger; - -import javax.enterprise.inject.Instance; -import javax.inject.Inject; - -/** - * @author Mike Brock - */ -public class FakeBean { - @Inject Bwah bwahBean; - - @Inject Instance instanceBar; - - public void testMethod() { - addSomething("foobie", BigInteger.class, BigDecimal.class); - } - - private void addSomething(final String name, final Class a, final Class b) { - // yay - } -} - diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/Foo.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/Foo.java deleted file mode 100644 index 7c3db743f78..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/Foo.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -import java.util.List; -import java.util.Map; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public class Foo { - public Bar bar; - - public static T foo(T t) { - return t; - } - - public static T bar(List list) { - return list.get(0); - } - - public static T bar(int n, List>> list) { - return null; - } - - public static V bar(Map map) { - return map.get(null); - } - - public static T baz(Class list) { - return null; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/GenericArrayCollectionTestModel.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/GenericArrayCollectionTestModel.java deleted file mode 100644 index b484d097d01..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/GenericArrayCollectionTestModel.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -import java.util.List; - -public class GenericArrayCollectionTestModel { - - public static List getGenericArrays() { - return null; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/GenericArraySubclass.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/GenericArraySubclass.java deleted file mode 100644 index 999fd07a168..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/GenericArraySubclass.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -/** - * - * @author Max Barkley - */ -public class GenericArraySubclass extends GenericSuperClass { - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/GenericSuperClass.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/GenericSuperClass.java deleted file mode 100644 index ab261c47eff..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/GenericSuperClass.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -/** - * - * @author Max Barkley - */ -public class GenericSuperClass { - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/HasBinding.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/HasBinding.java deleted file mode 100644 index 6a2fda5d140..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/HasBinding.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -/** - * Implementations can be bound to a variable - */ -public interface HasBinding { - - String getBinding(); - - void setBinding( String binding ); - - boolean isBound(); - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/HasManyConstructors.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/HasManyConstructors.java deleted file mode 100644 index 4324a6d7bd7..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/HasManyConstructors.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -/** - * - * @author Max Barkley - */ -public class HasManyConstructors { - public HasManyConstructors() {} - HasManyConstructors(final int arg) {} - protected HasManyConstructors(final String arg) {} - private HasManyConstructors(final double arg) {} -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/HasValue.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/HasValue.java deleted file mode 100644 index f68fe8e802a..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/HasValue.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -import java.io.Serializable; - -public interface HasValue { - - T getValue(); - - void setValue( T value ); - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/Integer.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/Integer.java deleted file mode 100644 index 542e1a5199e..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/Integer.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -/** - * The only purpose of this class is to simulate an import collision in {@see ClassBuilderTest}. - * - * @author Christian Sadilek - */ -public class Integer { - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/Mrshlr.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/Mrshlr.java deleted file mode 100644 index ced642a2820..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/Mrshlr.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -/** - * @author Mike Brock - */ -public interface Mrshlr { - public Class get(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/MultiAnno.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/MultiAnno.java deleted file mode 100644 index e90933184a5..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/MultiAnno.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * @author Mike Brock - */ -@Retention(RetentionPolicy.RUNTIME) -public @interface MultiAnno { - String[] value(); - - int age(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/MyBean.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/MyBean.java deleted file mode 100644 index 334f5946f02..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/MyBean.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -/** - * @author Mike Brock - */ - -@MyTestAnnotation(foo = "barfoo", testEum = TEnum.FOURTH) -public class MyBean { -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/MyTestAnnotation.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/MyTestAnnotation.java deleted file mode 100644 index 706e12846a3..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/MyTestAnnotation.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * @author Mike Brock - */ - -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD}) -public @interface MyTestAnnotation { - public String foo() default "foobar"; - - public TEnum testEum(); - } diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/ObjectWithNested.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/ObjectWithNested.java deleted file mode 100644 index 3d82cccd9b6..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/ObjectWithNested.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -/** - * @author Mike Brock - */ -public class ObjectWithNested { - public class MyNestedInterface implements TestInterface { - - } - - public MyNestedInterface getMyNestedInterface() { - return new MyNestedInterface(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/ParameterizedClass.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/ParameterizedClass.java deleted file mode 100644 index 14408e61a25..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/ParameterizedClass.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -public class ParameterizedClass { - - public T methodReturningTypeParameter() { - return null; - } - - public void methodAcceptingTypeParam(T param) { - // no op - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/Person.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/Person.java deleted file mode 100644 index de5e6916010..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/Person.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -public interface Person { - - public String getName(); - public int getAge(); - public Person getMother(); - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/PersonImpl.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/PersonImpl.java deleted file mode 100644 index 064ea814ba7..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/PersonImpl.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -public class PersonImpl implements Person { - - private String name; - private int age; - private Person mother; - - public PersonImpl(String name, int age, Person mother) { - super(); - this.name = name; - this.age = age; - this.mother = mother; - } - - @Override - public String getName() { - return name; - } - - @Override - public int getAge() { - return age; - } - - @Override - public Person getMother() { - return mother; - } - - public void setName(String name) { - this.name = name; - } - - public void setAge(int age) { - this.age = age; - } - - public void setMother(Person mother) { - this.mother = mother; - } - - @Override - public String toString() { - return "Person \"" + name + "\""; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/PortableIntegerParameterDefinition.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/PortableIntegerParameterDefinition.java deleted file mode 100644 index 0f7c41acaec..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/PortableIntegerParameterDefinition.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -import org.jboss.errai.common.client.api.annotations.Portable; - - -/** - * An Integer parameter - */ -@Portable -public class PortableIntegerParameterDefinition - extends PortableParameterDefinition - implements HasValue, - HasBinding { - - private String binding; - - private java.lang.Integer value; - - public PortableIntegerParameterDefinition() { - - } - - @Override - public java.lang.Integer getValue() { - return this.value; - } - - @Override - public void setValue( java.lang.Integer value ) { - this.value = value; - } - - @Override - public String getBinding() { - return this.binding; - } - - @Override - public void setBinding( String binding ) { - this.binding = binding; - } - - @Override - public String asString() { - if ( isBound() ) { - return this.getBinding(); - } - if ( this.value == null ) { - return "null"; - } - return java.lang.Integer.toString( this.value ); - } - - @Override - public String getClassName() { - return Integer.class.getName(); - } - - @Override - public boolean isBound() { - return ( this.getBinding() != null && !"".equals( this.getBinding() ) ); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/PortableParameterDefinition.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/PortableParameterDefinition.java deleted file mode 100644 index 752b6d718ce..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/PortableParameterDefinition.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -/** - * A ParameterDefinition used in Guvnor. - * @see org.drools.core.process.core.ParameterDefinition - */ -public abstract class PortableParameterDefinition { - - private String name; - - public PortableParameterDefinition() { - } - - public PortableParameterDefinition( String name ) { - setName( name ); - } - - public String getName() { - return name; - } - - public void setName( String name ) { - if ( name == null ) { - throw new IllegalArgumentException( "Name cannot be null" ); - } - this.name = name; - } - - public abstract String asString(); - - public abstract String getClassName(); - - public String getSimpleClassName() { - String className = getClassName(); - if ( className == null ) { - return null; - } - int index = className.lastIndexOf( "." ); - if ( index >= 0 ) { - className = className.substring( index + 1 ); - } - return className; - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/PrimitiveFieldContainer.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/PrimitiveFieldContainer.java deleted file mode 100644 index 62da685102e..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/PrimitiveFieldContainer.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -/** - * A class that has a field of every primitive type. This is relied upon by the - * mock type oracle in the GWT codegen tests, but you can use it for other tests - * if that's convenient. - * - * @author Jonathan Fuerth - */ -public class PrimitiveFieldContainer { - - // DO NOT RENAME OR REMOVE ANY OF THE FOLLOWING FIELDS - - byte byteField; - char charField; - short shortField; - int intField; - long longField; - float floatField; - double doubleField; - - void voidMethod() {} -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/SnapshotInterfaceWithCollections.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/SnapshotInterfaceWithCollections.java deleted file mode 100644 index 70e054bb008..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/SnapshotInterfaceWithCollections.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -import java.util.List; - -/** - * @author Mike Brock - */ -public interface SnapshotInterfaceWithCollections { - public List getPersons(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/SnapshotInterfaceWithCollectionsImpl.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/SnapshotInterfaceWithCollectionsImpl.java deleted file mode 100644 index 30298413bb3..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/SnapshotInterfaceWithCollectionsImpl.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -import java.util.List; - -/** - * @author Mike Brock - */ -public class SnapshotInterfaceWithCollectionsImpl implements SnapshotInterfaceWithCollections { - public List persons; - - public SnapshotInterfaceWithCollectionsImpl(List persons) { - this.persons = persons; - } - - @Override - public List getPersons() { - return persons; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/TEnum.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/TEnum.java deleted file mode 100644 index cb04caa2785..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/TEnum.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -/** - * @author Mike Brock - */ -public enum TEnum { - FIRST, SECOND, THIRD, FOURTH -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/TestInterface.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/TestInterface.java deleted file mode 100644 index fd9570c873d..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/TestInterface.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -/** - * The only purpose of this class is to simulate an import collision in {@see ClassBuilderTest}. - * - * @author Christian Sadilek - */ -public interface TestInterface { - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/ToProxyBean.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/ToProxyBean.java deleted file mode 100644 index f327d7bff51..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/ToProxyBean.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -import java.lang.annotation.Annotation; - -import com.google.common.collect.Multimap; - -/** - * @author Mike Brock - */ -public class ToProxyBean { - protected String name; - protected Integer blah; - - public ToProxyBean() { - } - - public ToProxyBean(String name, Integer blah) { - this.name = name; - this.blah = blah; - } - - public String getName() { - return name; - } - - public Integer getBlah() { - return blah; - } - - public void methodWithTypeArgs(Class annotation, Multimap map) { - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/ToProxyBean2.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/ToProxyBean2.java deleted file mode 100644 index 303ea1834f4..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/ToProxyBean2.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model; - -/** - * @author Mike Brock - */ -public class ToProxyBean2 { - - -// public static class BlahBean extends ToProxyBean2 { -// @Override -// public void proxyMethod(Class annotation, Map map) { -// super.proxyMethod(annotation, map); -// } -// -// } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/tree/Child.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/tree/Child.java deleted file mode 100644 index bb7374d7192..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/tree/Child.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model.tree; - -/** - * Centre of the "Family Tree" class hierarchy for testing purposes. - * - * @author Jonathan Fuerth - */ -public class Child extends Parent { - - private int childPrivate; - int childPackage; - protected int childProtected; - public int childPublic; - - @Override - public void interfaceMethodOverriddenMultipleTimes() {} - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/tree/Grandparent.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/tree/Grandparent.java deleted file mode 100644 index eaf853e6c49..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/tree/Grandparent.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model.tree; - -public class Grandparent implements GrandparentInterface { - - @Override - public void interfaceMethodOverriddenMultipleTimes() {} - - void packagePrivateMethod() {}; - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/tree/GrandparentInterface.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/tree/GrandparentInterface.java deleted file mode 100644 index efac8e8706c..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/tree/GrandparentInterface.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model.tree; - -public interface GrandparentInterface extends GrandparentSuperInterface { - - void interfaceMethodOverriddenMultipleTimes(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/tree/GrandparentSuperInterface.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/tree/GrandparentSuperInterface.java deleted file mode 100644 index 3c55f8baba0..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/tree/GrandparentSuperInterface.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model.tree; - -public interface GrandparentSuperInterface { - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/tree/IsolatedInterface.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/tree/IsolatedInterface.java deleted file mode 100644 index 1080cc3162a..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/tree/IsolatedInterface.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model.tree; - -/** - * An interface that's not connected to the family tree. - * - * @author Jonathan Fuerth - */ -public interface IsolatedInterface { - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/tree/Parent.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/tree/Parent.java deleted file mode 100644 index ba7f60ba566..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/tree/Parent.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model.tree; - -public class Parent extends Grandparent implements ParentInterface { - - private int parentPrivate; - int parentPackage; - protected int parentProtected; - public int parentPublic; - - @Override - public void interfaceMethodOverriddenMultipleTimes() {} - - private void privateMethod() {}; - - protected void protectedMethod() {}; - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/tree/ParentInterface.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/tree/ParentInterface.java deleted file mode 100644 index e601d0c059b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/tree/ParentInterface.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model.tree; - -public interface ParentInterface extends ParentSuperInterface1, ParentSuperInterface2 { - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/tree/ParentSuperInterface1.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/tree/ParentSuperInterface1.java deleted file mode 100644 index f0113a32347..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/tree/ParentSuperInterface1.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model.tree; - -public interface ParentSuperInterface1 { - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/tree/ParentSuperInterface2.java b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/tree/ParentSuperInterface2.java deleted file mode 100644 index d5bdd599ce0..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/java/org/jboss/errai/codegen/test/model/tree/ParentSuperInterface2.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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 org.jboss.errai.codegen.test.model.tree; - -public interface ParentSuperInterface2 { - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/resources/log4j.properties b/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/resources/log4j.properties deleted file mode 100644 index 7d35540d698..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-codegen/src/test/resources/log4j.properties +++ /dev/null @@ -1,28 +0,0 @@ -# -# 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. -# - -log4j.rootLogger=INFO, A1 -log4j.appender.A1=org.apache.log4j.ConsoleAppender -log4j.appender.A1.layout=org.apache.log4j.PatternLayout -log4j.appender.A1.layout.ConversionPattern=%d %-5p %c - %m%n - -log4j.logger=INFO - -#log4j.logger.org.jboss.errai.reflections=DEBUG -#log4j.logger.org.jboss.errai.ioc.rebind.ioc.bootstrapper=DEBUG diff --git a/packages/serverless-workflow-diagram-editor/errai-common/pom.xml b/packages/serverless-workflow-diagram-editor/errai-common/pom.xml deleted file mode 100644 index 4ab9e8edb9e..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/pom.xml +++ /dev/null @@ -1,184 +0,0 @@ - - 4.0.0 - Errai::Common - errai-common - jar - - - - org.kie.kogito.stunner.serverless.editor - stunner-editors-parent - ${revision} - ../pom.xml - - - - - org.jboss.spec.javax.servlet - jboss-servlet-api_3.1_spec - provided - - - - org.gwtproject - gwt-user - provided - - - javax.servlet - javax.servlet-api - - - - - - org.gwtproject - gwt-dev - provided - - - javax.servlet - javax.servlet-api - - - org.eclipse.jetty - jetty-annotations - - - - - - com.google.inject - guice - provided - - - - com.google.jsinterop - jsinterop-annotations - - - - org.kie.kogito.stunner.serverless.editor - reflections - - - org.jboss.spec.javax.servlet - jboss-servlet-api_3.1_spec - - - com.google.code.gson - gson - - - ch.qos.logback - logback-classic - - - - - - junit - junit - - - - org.jboss.shrinkwrap - shrinkwrap-api - test - - - - org.jboss.shrinkwrap - shrinkwrap-impl-base - test - - - - de.benediktmeurer.gwt-slf4j - gwt-slf4j - - - - org.apache.commons - commons-lang3 - - - - org.mockito - mockito-core - test - - - - org.powermock - powermock-module-junit4 - test - - - org.objenesis - objenesis - - - net.bytebuddy - byte-buddy-agent - - - - - - org.powermock - powermock-api-mockito2 - test - - - - com.google.elemental2 - elemental2-dom - - - - - - - integration-test - - - - maven-surefire-plugin - - - - **/it/**/*.java - - - **/*Tests.java - **/*Test.java - - - - - maven-failsafe-plugin - - - **/it/**/*Tests.java - **/it/**/*Test.java - - - - - org.codehaus.mojo - selenium-maven-plugin - - true - - - - - - - diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/ErraiCommon.gwt.xml b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/ErraiCommon.gwt.xml deleted file mode 100644 index 2f5b44b1974..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/ErraiCommon.gwt.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/Logging.gwt.xml b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/Logging.gwt.xml deleted file mode 100644 index 874008b7b1c..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/Logging.gwt.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/InitCoordinator.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/InitCoordinator.java deleted file mode 100644 index 1916b714cca..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/InitCoordinator.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 org.jboss.errai.common.client; - -import com.google.gwt.core.client.EntryPoint; -import org.jboss.errai.common.client.api.extension.InitVotes; - -/** - * @author Mike Brock - */ -public class InitCoordinator implements EntryPoint { - @Override - public void onModuleLoad() { - InitVotes.startInitPolling(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/PageRequest.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/PageRequest.java deleted file mode 100644 index 70508a437df..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/PageRequest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 org.jboss.errai.common.client; - -import java.util.Map; - -import org.jboss.errai.common.client.api.annotations.MapsTo; -import org.jboss.errai.common.client.api.annotations.Portable; - -/** - * @author edewit@redhat.com - */ -@Portable -public class PageRequest { - private final String pageName; - private final Map state; - - public PageRequest(@MapsTo("pageName") String pageName, @MapsTo("state") Map state) { - this.pageName = pageName; - this.state = state; - } - - public String getPageName() { - return pageName; - } - - public Map getState() { - return state; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/Assert.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/Assert.java deleted file mode 100644 index 9295752d84f..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/Assert.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api; - -/** - * Non-instantiable utility for self-checking code. - * - * @author Christian Sadilek - * @author Jonathan Fuerth - * @author Mike Brock - */ -public class Assert { - - private Assert() {} - - /** - * Throws NullPointerException if the value is null with an error message. - * - * @param - * @param errorMessage an error message to be displayed as part of the NullPointerException thrown. - * @param value the value that must not be null - * @throws NullPointerException if value is null. - * @return - */ - public static V notNull(final String errorMessage, final V value) { - if (value == null) { - throw new NullPointerException(errorMessage); - } - return value; - } - - /** - * Throws NullPointerException if the value is null. - * - * @param - * @param value the value that must not be null - * @throws NullPointerException if value is null. - * @return - */ - public static V notNull(final V value) { - if (value == null) { - throw new NullPointerException(); - } - return value; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/BatchCaller.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/BatchCaller.java deleted file mode 100644 index 5a0df01f67d..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/BatchCaller.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api; - -/** - * An interface that can be used as an injection point for batched invocations of remote methods using generated - * proxies. In contrast to {@link Caller}, no remote request will be sent until {@link #sendBatch()} is called. - * - * @author Christian Sadilek - */ -public interface BatchCaller { - - /** - * Returns an instance of the proxy that can schedule invocations on service methods on the service described by - * {@code T}. - * - * @param callback - * the callback to be invoked when the remote call has completed in success. In the case of an error, a - * default error callback will be notified. Which one depends on the proxy implementation. - *

- * The provided callback must not be null. - * @param remoteService - * The interface describing the remote endpoint. - * - * @return an instance of the proxy that can invoke service methods on the service described by {@code T}. - */ - public T call(RemoteCallback callback, Class remoteService); - - /** - * Returns an instance of the proxy that can schedule invocations on service methods on the service described by - * {@code T}. - * - * @param callback - * the callback to be invoked when the remote call has completed in success. In the case of an error, a - * default error callback will be notified. Which one depends on the proxy implementation. - *

- * The callback must not be null. - * @param errorCallback - * the callback to be invoked when the remote call has completed in failure. No callback is invoked in the - * case of success. - *

- * The provided callback must not be null. - * @param remoteService - * The interface describing the remote endpoint. - * - * @return an instance of the proxy that can invoke service methods on the service described by {@code T}. - */ - public T call(RemoteCallback callback, ErrorCallback errorCallback, Class remoteService); - - /** - * Invokes the accumulated remote requests using a single server round trip. - */ - public void sendBatch(); - - /** - * Invokes the accumulated remote requests using a single server round trip. - * - * @param callback - * the callback to be invoked when all remote calls have completed in success. Must not be null. - */ - public void sendBatch(RemoteCallback callback); - - /** - * Invokes the accumulated remote requests using a single server round trip. - * - * @param errorCallback - * the callback to be invoked for all remote calls that have completed in failure. No callback is invoked - * in the case of success. - */ - public void sendBatch(ErrorCallback errorCallback); - - /** - * Invokes the accumulated remote requests using a single server round trip. - * - * @param callback - * the callback to be invoked when all remote calls have completed in success. Must not be null. - * @param errorCallback - * the callback to be invoked for all remote calls that have completed in failure. - */ - public void sendBatch(RemoteCallback callback, ErrorCallback errorCallback); - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/Caller.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/Caller.java deleted file mode 100644 index e387eeece58..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/Caller.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api; - - - -/** - * An interface that can be used as the injection point for a (probably - * generated) proxy that invokes remote methods and gives their return values to - * the supplied callbacks. - * - * @author Mike Brock - */ -public interface Caller { - - /** - * Returns an instance of the proxy that can invoke service methods on the - * service described by {@code T}. - * - * @return an instance of the proxy that can invoke service methods on the - * service described by {@code T}. - */ - public T call(); - - /** - * Returns an instance of the proxy that can invoke service methods on the - * service described by {@code T}. - * - * @param callback - * the callback to be invoked when the remote call has completed in - * success. In the case of an error, a default error callback will be - * notified. Which one depends on the proxy implementation. - *

- * The provided callback must not be null. - * @return an instance of the proxy that can invoke service methods on the - * service described by {@code T}. - */ - public T call(RemoteCallback callback); - - /** - * Returns an instance of the proxy that can invoke service methods on the - * service described by {@code T}. - * - * @param callback - * the callback to be invoked when the remote call has completed in - * success. In the case of an error, a default error callback will be - * notified. Which one depends on the proxy implementation. - *

- * The callback must not be null. - * @param errorCallback - * the callback to be invoked when the remote call has completed - * in failure. No callback is invoked in the case of success. - *

- * The provided callback must not be null. - * @return an instance of the proxy that can invoke service methods on the - * service described by {@code T}. - */ - public T call(RemoteCallback callback, ErrorCallback errorCallback); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/ErrorCallback.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/ErrorCallback.java deleted file mode 100644 index 3df03be806f..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/ErrorCallback.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api; - -/** - * Callback interface for failed delivery of specific messages for which an error handler has been provided using the - * {@code MessageBuilder} API. - *

- * Errors can also be handled globally by subscribing a regular to the bus topic - * DefaultErrorCallback.CLIENT_ERROR_SUBJECT. - * - * @author Mike Brock - */ -public interface ErrorCallback { - - /** - * Called when an error occurs on the bus. - * - * @param message - * The message or request for which the failure occurred. - * @param throwable - * The exception thrown or null if not available - * - * @return boolean indicating whether or not the default error handling should be performed. - */ - public boolean error(T message, Throwable throwable); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/IsElement.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/IsElement.java deleted file mode 100644 index 0435f83fb32..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/IsElement.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api; - -import com.google.gwt.dom.client.Element; -import com.google.gwt.user.client.ui.IsWidget; -import elemental2.dom.HTMLElement; - -/** - * - * @deprecated Use Elemental 2 for new development - * - * This interface is analogous to {@link IsWidget}, but for views built with native DOM wrappers. - * - * Extended by view interfaces that are likely to be implemented by native elements. - * Provides access to that widget, if it exists, without compromising the - * ability to provide a mock view instance in JRE unit tests. - * - * @author Max Barkley - */ -@Deprecated -public interface IsElement { - - /** - * @return The {@link Element} aspect of the implementor. - */ - HTMLElement getElement(); - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/NoOpCallback.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/NoOpCallback.java deleted file mode 100644 index 110d9cad76f..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/NoOpCallback.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api; - -/** - * @author Mike Brock - */ -public class NoOpCallback implements RemoteCallback { - @Override - public void callback(final T response) { - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/RemoteCallback.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/RemoteCallback.java deleted file mode 100644 index f4e29d307ef..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/RemoteCallback.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api; - -/** - * Callback interface for receiving the response of an RPC call, regardless of the RPC mechanism. - * - * @see MessageBuilder#createCall() - * @see MessageBuilder#createCall(RemoteCallback, Class) - * @see MessageBuilder#createCall(RemoteCallback, ErrorCallback, Class) - * @see the Errai JAX-RS client module - * @param - * type of response the callback expects. Use {@link Void} for methods returning {@code void}. - */ -public interface RemoteCallback { - - /** - * Invoked by the RPC proxy after the remote method has been executed and its - * response has been received. - * - * @param response - * the response returned from the remote call. Will be null if the - * remote method returns null or has a void return type. - */ - public void callback(R response); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/ResourceProvider.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/ResourceProvider.java deleted file mode 100644 index e5fbfe85ac0..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/ResourceProvider.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api; - -/** - * Provides injectable resources of type T. - * - * @param injection target type - */ -public interface ResourceProvider { - public T get(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/BrowserEvent.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/BrowserEvent.java deleted file mode 100644 index 7d49862457e..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/BrowserEvent.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api.annotations; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -/** - * Marks a native {@link JsType} as a wrapper for a DOM event. {@link BrowserEvent#value()} are the event type names - * that the annotated type can be used with (i.e. click, dblclick, change, etc.). A type annotated with - * {@code BrowserEvent} can be used with the {@code @EventHandler} annotation in Errai UI templates. - * - * @author Max Barkley - */ -@Retention(RUNTIME) -@Documented -@Target(TYPE) -public @interface BrowserEvent { - - /** - * A list of event types supported by this event (i.e. click, dblclick, change). If this value has length 0 then the - * annotated type supports all browser event types. - */ - String[] value() default {}; - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/ClassNames.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/ClassNames.java deleted file mode 100644 index 3e4d149c057..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/ClassNames.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api.annotations; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Used when declaring a type with {@link Element}. Indicates that the declared {@link Element} will have the class. - * - * @author Dmitrii Tikhomirov - * Created by treblereel on 11/14/17. - */ -@Retention(RetentionPolicy.RUNTIME) -@Documented -@Target(ElementType.TYPE) -public @interface ClassNames { - - /** - * The value of a DOM element class. - */ - String[] value(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/Element.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/Element.java deleted file mode 100644 index c844063aa2e..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/Element.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api.annotations; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -import jsinterop.annotations.JsType; - -/** - * Marks a native {@link JsType} as a wrapper for a DOM element. {@link Element#value()} are the tag names of the - * element. Errai IoC will generate code calling {@code document.createElement} for injecting instances of types - * annotated with {@linkplain Element}. When multiple tag names are specified, injection sites must use {@code javax.inject.Named} to - * remove ambiguity at injection sites. - * - * @author Max Barkley - */ -@Retention(RetentionPolicy.RUNTIME) -public @interface Element { - - String[] value(); - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/IOCProducer.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/IOCProducer.java deleted file mode 100644 index 733e274a73c..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/IOCProducer.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api.annotations; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -/** - * Indicates that the annotated field or method produces a managed bean. - * - * @see Produces - * @author Max Barkley - */ -@Documented -@Retention(RUNTIME) -@Target({FIELD, METHOD}) -public @interface IOCProducer { - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/LocalEvent.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/LocalEvent.java deleted file mode 100644 index b23822cae64..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/LocalEvent.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api.annotations; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Indicates that instances of the annotated class should not be sent over the wire when fired as - * Errai CDI Events. - * - * This annotation is only useful in conjunction with @Portable. - * - * @since Errai 3.0 - * @author Max Barkley - */ -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface LocalEvent { - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/MapsTo.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/MapsTo.java deleted file mode 100644 index 8160e805162..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/MapsTo.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * @author Mike Brock - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.PARAMETER) -public @interface MapsTo { - String value(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/NamedLogger.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/NamedLogger.java deleted file mode 100644 index 29deddc68b1..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/NamedLogger.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.slf4j.Logger; - -/** - * When injecting a {@link Logger}, this annotation can be used to specify a - * name. If this annotation is used but no value is given, the root logger will - * be provided. - * - * Example usage: - * - *

- * // Gets root logger
- * {@literal @Inject @NamedLogger} Logger logger;
- * 
- * // Gets logger with name 'LoggerName'
- * {@literal @Inject @NamedLogger("LoggerName")} Logger logger;
- * 
- * - * @author mbarkley - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface NamedLogger { - String value() default org.slf4j.Logger.ROOT_LOGGER_NAME; -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/NonPortable.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/NonPortable.java deleted file mode 100644 index 00aa7e649a7..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/NonPortable.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api.annotations; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Indicates that instances of the annotated class are not eligible to be serialized and sent over the wire between - * server and clients. - *

- * This annotation is only expected to be useful for classes nested in a portable class: nested classes are portable by - * default, unless annotated with {@code @NotPortable}. - * - * @since Errai 2.0 - * @author Christian Sadilek - * @author Jonathan Fuerth - */ -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface NonPortable { - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/Portable.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/Portable.java deleted file mode 100644 index 19f20063c03..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/Portable.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api.annotations; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Indicates that instances of the annotated class are eligible to be serialized - * and sent over the wire between server and clients. - *

- * - * @since Errai 2.0 - * @author Mike Brock - */ -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface Portable { - /** - * Indicate that the annotated class should be treated as an alias of an existing marshalling mapping, and should - * not be directly mapped itself. - * @return - */ - Class aliasOf() default Object.class; - - /* - * Indicate that concrete supertypes of the annotated class should have marshalling mappings generated as if marked - * portable. - */ - boolean mapSuperTypes() default false; -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/Properties.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/Properties.java deleted file mode 100644 index 03bb05b6c83..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/Properties.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api.annotations; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Used when declaring a type with {@link Element}. Indicates that the declared {@link Element} will have the all the - * declared {@link Property properties}. - * - * @author Max Barkley - */ -@Retention(RetentionPolicy.RUNTIME) -@Documented -@Target(ElementType.TYPE) -public @interface Properties { - - Property[] value(); - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/Property.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/Property.java deleted file mode 100644 index b38dbf713d8..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/annotations/Property.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api.annotations; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Used when declaring a type with {@link Element}. Indicates that the declared {@link Element} will have the property, - * {@link #name()} with the value, {@link #value()}. - * - * @author Max Barkley - */ -@Retention(RetentionPolicy.RUNTIME) -@Documented -@Target(ElementType.TYPE) -public @interface Property { - - /** - * The name of a DOM element property. - */ - String name(); - - /** - * The value of a DOM element property. - */ - String value(); - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/elemental2/IsElement.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/elemental2/IsElement.java deleted file mode 100644 index 516711e1f4d..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/elemental2/IsElement.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api.elemental2; - -import com.google.gwt.user.client.ui.IsWidget; -import elemental2.dom.Element; -import elemental2.dom.HTMLElement; - -/** - * This interface is analogous to {@link IsWidget}, but for views built with native DOM wrappers. - * - * Extended by view interfaces that are likely to be implemented by native elements. - * Provides access to that widget, if it exists, without compromising the - * ability to provide a mock view instance in JRE unit tests. - * - * @author Tiago Bento - */ -public interface IsElement { - - /** - * @return The {@link Element} aspect of the implementor. - */ - HTMLElement getElement(); - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/extension/InitFailureListener.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/extension/InitFailureListener.java deleted file mode 100644 index 4a2c4d5de2c..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/extension/InitFailureListener.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api.extension; - -import java.util.Set; - -/** - * An InitFailureListener is used to listen for components which do not initialize as part of the - * framework bootstrap at runtime. Generally, framework components are bootstrapped based on class-based - * topic. The appearance of one of - * these topics in the {@link Set} passed to the {@link #onInitFailure(java.util.Set)} method indicates - * this component timed out and did not initialize. - * - * @author Mike Brock - */ -public interface InitFailureListener { - - /** - * Called when an initialization failure occurs. - * - * @param failedTopics - * Represents a set of initialization topics which did not initialize. These are typically - * based on the fully-qualified class names of components. - */ - public void onInitFailure(Set failedTopics); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/extension/InitVotes.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/extension/InitVotes.java deleted file mode 100644 index fcdf211cb5a..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/extension/InitVotes.java +++ /dev/null @@ -1,439 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api.extension; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.google.gwt.core.client.GWT; -import org.jboss.errai.common.client.api.tasks.AsyncTask; -import org.jboss.errai.common.client.api.tasks.TaskManagerFactory; -import org.jboss.errai.common.client.util.TimeUnit; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - *

- * The InitVotes class provides the central algorithm around which disparate services within the Errai - * Framework can elect to prevent initialization and be notified when initialization occurs. This is required internally - * to ensure that services such as RPC proxies have been properly bound prior to any remote calls being made. This API - * also makes it possible for user-defined services and extensions to Errai to participate in the startup contract. - * - *

- * Initialization fails if there are any services still waiting after the timeout duration has elapsed. By default the - * timeout is 90 seconds for Development Mode and 45 seconds for production mode, but it can be adjusted by setting the - * Javascript variable erraiInitTimeout in the GWT Host Page. - * - * @author Mike Brock - */ -public final class InitVotes { - private InitVotes() {} - - private static final List preInitCallbacks = new ArrayList<>(); - private static final Map> dependencyCallbacks = new HashMap<>(); - private static final List initCallbacks = new ArrayList<>(); - private static final List initFailureListeners = new ArrayList<>(); - - private static boolean armed = false; - private static boolean init = false; - private static final Set waitForSet = new HashSet<>(); - - // a list of both strings and runnable references that are marked done. - private static final Set completedSet = new HashSet<>(); - - private static int timeoutMillis = !GWT.isProdMode() ? 90000 : 45000; - - private static volatile AsyncTask initTimeout; - private static volatile AsyncTask initDelay; - - private static boolean _initWait = false; - - private static final Object lock = new Object(); - - private static final Logger logger = LoggerFactory.getLogger(InitVotes.class); - - /** - * Resets the state, clearing all current waiting votes and disarming the startup process. Calling - * reset() does not however clear out any initialization callbacks registered with - * {@link #registerPersistentInitCallback(Runnable)}. - */ - public static void reset() { - synchronized (lock) { - logger.info("init polling system reset ..."); - - idempotentStopFailTimer(); - idempotentStopDelayTimer(); - _clearOneTimeRunnables(preInitCallbacks); - _clearOneTimeRunnables(initCallbacks); - for (final Map.Entry> entry : dependencyCallbacks.entrySet()) { - _clearOneTimeRunnables(entry.getValue()); - } - waitForSet.clear(); - completedSet.clear(); - armed = false; - init = false; - } - } - - private static native int getConfiguredTimeoutOrElse(final int fallback) /*-{ - var configuredValue = $wnd.erraiInitTimeout; - return (configuredValue == undefined || configuredValue <= 0) ? - fallback : - configuredValue; - }-*/; - - /** - * Specifies the number of milliseconds that will be permitted to transpire until dependencies are - * assumed to have failed to satisfy, and thus an error is rendered to the browser console. - * - * @param millis - * milliseconds. - */ - public static void setTimeoutMillis(final int millis) { - timeoutMillis = millis; - }; - - /** - * Declares a startup dependency on the specified class. By doing so, initialization of the - * framework services will be blocked until a {@link #voteFor(Class)} is called with the same - * Class reference passed to this method. - *

- * If no dependencies have previously been declared, then the first caller to invoke this method - * arms and begins the startup process. This starts the timer window (see - * {@link #setTimeoutMillis(int)}) for which all components being waited on are expected to report - * back that they're ready. - * - * @param clazz - * a class reference. - * - * @see #voteFor(Class) - */ - public static void waitFor(final Class clazz) { - waitFor(clazz.getName()); - } - - private static void waitFor(final String topic) { - synchronized (lock) { - if (completedSet.contains(topic)) { - // throw new RuntimeException("cannot declare a wait on '" + topic + - // "' as it is already marked completed!"); - return; - } - - if (waitForSet.contains(topic)) - return; - - logger.info("wait for: " + topic); - - if (!armed && waitForSet.isEmpty()) { - beginInit(); - } - - waitForSet.add(topic); - } - } - - public static boolean isInitialized() { - return init; - } - - /** - * Votes for initialization and removes a lock on the initialization of framework services. If the - * initialization process has been armed and this vote releases the final dependency, the - * initialization process will be triggered, calling all the registered initialization callbacks. - * See: {@link #registerPersistentInitCallback(Runnable)} - * - * @param clazz - * a class reference - */ - public static void voteFor(final Class clazz) { - voteFor(clazz.getName()); - } - - private static void voteFor(final String topic) { - synchronized (lock) { - if (waitForSet.remove(topic)) { - logger.info("vote for: " + topic); - - completedSet.add(topic); - } - - _runAllRunnables(dependencyCallbacks.get(topic)); - - if (!waitForSet.isEmpty()) - logger.info(" still waiting for -> " + waitForSet); - - if (armed && waitForSet.isEmpty()) { - scheduleFinish(); - } - } - } - - private static void scheduleFinish() { - if (_initWait) - return; - - logger.debug("Scheduling finish."); - _initWait = true; - - _scheduleFinish(new Runnable() { - @Override - public void run() { - logger.debug("Running finish timer..."); - if (armed && waitForSet.isEmpty()) { - idempotentStopFailTimer(); - finishInit(); - _initWait = false; - } - else { - logger.debug("Rescheduling finish."); - _scheduleFinish(this); - } - } - }); - } - - private static void _scheduleFinish(final Runnable runnable) { - initDelay = TaskManagerFactory.get().schedule(TimeUnit.MILLISECONDS, 250, runnable); - } - - public static void registerPersistentDependencyCallback(final Class clazz, final Runnable runnable) { - _registerDependencyCallback(clazz.getName(), runnable); - } - - public static void registerOneTimeDependencyCallback(final Class clazz, final Runnable runnable) { - registerPersistentDependencyCallback(clazz, new OneTimeRunnable(runnable)); - } - - private static void _registerDependencyCallback(final String topic, final Runnable runnable) { - synchronized (lock) { - List callbacks = dependencyCallbacks.get(topic); - if (callbacks == null) { - dependencyCallbacks.put(topic, callbacks = new ArrayList<>()); - } - if (!callbacks.contains(runnable)) { - callbacks.add(runnable); - } - - if (completedSet.contains(topic) && !completedSet.contains(runnable)) { - runnable.run(); - } - } - } - - public static void registerPersistentPreInitCallback(final Runnable runnable) { - synchronized (lock) { - if (!preInitCallbacks.contains(runnable)) { - preInitCallbacks.add(runnable); - - if (armed) { - runnable.run(); - } - } - } - } - - public static void registerOneTimePreInitCallback(final Runnable runnable) { - registerPersistentPreInitCallback(new OneTimeRunnable(runnable)); - } - - /** - * Registers a callback task to be executed once initialization occurs. Callbacks registered with - * this method will be persistent across multiple initializations, and will not be - * cleared out even if {@link #reset()} is called. If this is not desirable, see: - * {@link #registerOneTimeInitCallback}; - *

- * As of Errai 3.0, the callback list is de-duped based on instance to simplify initialization - * code in modules. You can now safely re-add a Runnable in initialization code as long as it is - * always guaranteed to be the same instance.* - * - * @param runnable - * a callback to execute - */ - public static void registerPersistentInitCallback(final Runnable runnable) { - synchronized (lock) { - if (!initCallbacks.contains(runnable)) { - initCallbacks.add(runnable); - } - if (init) { - _runAllRunnables(Arrays.asList(runnable), initCallbacks); - } - } - } - - /** - * Registers a one-time callback task to be executed once initialization occurs. Unlike callbacks - * registered with {@link #registerPersistentInitCallback(Runnable)} Callback(Runnable)}, - * callbacks registered with this method will only be executed once and will never be used again - * if framework services are re-initialized. - * - * @param runnable - * a callback to execute - */ - public static void registerOneTimeInitCallback(final Runnable runnable) { - registerPersistentInitCallback(new OneTimeRunnable(runnable)); - } - - /** - * Registers an {@link InitFailureListener} to monitor for initialization failures of the - * framework or its components. - * - * @param failureListener - * the instance of the {@link InitFailureListener} to be registered. - */ - public static void registerInitFailureListener(final InitFailureListener failureListener) { - initFailureListeners.add(failureListener); - } - - public static void startInitPolling() { - if (armed) { - logger.warn("did not start polling. already armed."); - return; - } - logger.info("Starting init polling."); - timeoutMillis = getConfiguredTimeoutOrElse(timeoutMillis); - beginInit(); - } - - private static void beginInit() { - synchronized (lock) { - if (armed) { - throw new RuntimeException("attempt to arm voting process more than once."); - } - - armed = true; - _initWait = false; - idempotentStopFailTimer(); - - initTimeout = TaskManagerFactory.get().schedule(TimeUnit.MILLISECONDS, timeoutMillis, new Runnable() { - @Override - public void run() { - synchronized (lock) { - if (waitForSet.isEmpty() || !armed) - return; - - idempotentStopDelayTimer(); - - final Set failedTopics = Collections.unmodifiableSet(new HashSet<>(waitForSet)); - _fireFailedInit(failedTopics); - - logger.error("components failed to initialize"); - for (final String comp : waitForSet) { - logger.error(" [failed] -> " + comp); - } - } - } - }); - - _runAllRunnables(preInitCallbacks); - } - } - - private static void _fireFailedInit(final Set failedTopics) { - for (final InitFailureListener initFailureListener : initFailureListeners) { - initFailureListener.onInitFailure(failedTopics); - } - } - - private static void finishInit() { - synchronized (lock) { - logger.debug("Finishing initialization..."); - armed = false; - init = true; - idempotentStopFailTimer(); - - _runAllRunnables(initCallbacks); - } - } - - private static void idempotentStopFailTimer() { - synchronized (lock) { - if (initTimeout != null && !initTimeout.isFinished()) { - initTimeout.cancel(true); - } - } - } - - private static void idempotentStopDelayTimer() { - synchronized (lock) { - if (initDelay != null && !initDelay.isFinished()) { - initDelay.cancel(true); - } - } - } - - private static void _runAllRunnables(final List runnables) { - if (runnables == null || runnables.isEmpty()) - return; - _runAllRunnables(new ArrayList<>(runnables), runnables); - - } - - private static void _runAllRunnables(final List curRunnables, final List allRunnables) { - for (final Runnable runnable : curRunnables) { - if (completedSet.contains(runnable)) { - continue; - } - completedSet.add(runnable); - - if (runnable instanceof OneTimeRunnable) { - allRunnables.remove(runnable); - } - final int expectedSize = allRunnables.size(); - runnable.run(); - if (expectedSize < allRunnables.size()) { - // this runnable added more runnables that need to be executed - final List moreRunnables = new ArrayList<>(allRunnables).subList(expectedSize, allRunnables.size()); - _runAllRunnables(moreRunnables, allRunnables); - } - } - } - - private static void _clearOneTimeRunnables(final List runnables) { - final Iterator runnableIterable = runnables.iterator(); - while (runnableIterable.hasNext()) { - final Runnable runnable = runnableIterable.next(); - if (runnable instanceof OneTimeRunnable) { - runnableIterable.remove(); - } - } - } - - private static class OneTimeRunnable implements Runnable { - private final Runnable delegate; - - private OneTimeRunnable(final Runnable delegate) { - this.delegate = delegate; - } - - @Override - public void run() { - delegate.run(); - } - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/interceptor/CallContext.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/interceptor/CallContext.java deleted file mode 100644 index 423bea0db36..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/interceptor/CallContext.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api.interceptor; - -import java.lang.annotation.Annotation; - -import org.jboss.errai.common.client.api.Assert; -import org.jboss.errai.common.client.api.RemoteCallback; - -/** - * Represents the context of an intercepted method call. - * - * @author Christian Sadilek - */ -abstract class CallContext { - private Object[] parameters; - - /** - * Provides access to the intercepted method's parameters. - * - * @return Array of method parameters in declaration order. An empty array if the intercepted method has no - * parameters. - */ - public Object[] getParameters() { - return parameters; - } - - /** - * Overrides the parameters that are passed to the method for which the interceptor was invoked. - * - * @param parameters - * the parameters to use when invoking the intercepted method. Must not be null. - */ - public void setParameters(Object[] parameters) { - this.parameters = Assert.notNull(parameters); - } - - /** - * Returns the name of the intercepted method. - * - * @return the name of the method for which the interceptor was invoked. - */ - public abstract String getMethodName(); - - /** - * Returns the return type of the intercepted method. - * - * @return the return type of the method for which the interceptor was invoked. - */ - public abstract Class getReturnType(); - - /** - * Returns the annotations of the intercepted method. - * - * @return the annotations of the method of which the interceptor was invoked. - */ - public abstract Annotation[] getAnnotations(); - - /** - * Get the annotations of the intercepted type. - * - * @return the annotations of the type on which the interceptor was invoked. - */ - public abstract Annotation[] getTypeAnnotations(); - - /** - * Proceeds to the next interceptor in the chain or with the execution of the intercepted method if all - * interceptors have been executed. - *

- * This method can also be called to proceed with an asynchronous call (e.g. when intercepting a remote procedure - * call), but only if the call's result is not required in the interceptor logic. If access to the result of an - * asynchronous method call is needed in the interceptor, one of the overloaded versions of this method accepting a - * {@link RemoteCallback} has to be used instead. - * - * @return the return value of the intercepted method. Always null for asynchronous methods. - */ - public abstract Object proceed(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/interceptor/CallInterceptor.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/interceptor/CallInterceptor.java deleted file mode 100644 index 7dd2df69c08..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/interceptor/CallInterceptor.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api.interceptor; - -/** - * Represents an interceptor for either synchronous or asynchronous (remote) method calls. - * - * @author Christian Sadilek - * - * @param - * type of {@link CallContext} - */ -interface CallInterceptor { - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/interceptor/FeatureInterceptor.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/interceptor/FeatureInterceptor.java deleted file mode 100644 index 9b91c2a4e26..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/interceptor/FeatureInterceptor.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api.interceptor; - -import java.lang.annotation.Annotation; -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE}) -public @interface FeatureInterceptor { - - Class[] value(); - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/interceptor/InterceptedCall.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/interceptor/InterceptedCall.java deleted file mode 100644 index 767b204370e..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/interceptor/InterceptedCall.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api.interceptor; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Indicates that calls to the annotated method will be intercepted by the specified interceptor(s). When used on - * a class or interface, all methods of the corresponding type will be intercepted. - * - * @author Christian Sadilek - */ -@Documented -@Target({ ElementType.TYPE, ElementType.METHOD }) -@Retention(RetentionPolicy.RUNTIME) -public @interface InterceptedCall { - - /** - * The interceptor type(s) to use. Interceptor execution is guaranteed to be in declaration order. - */ - Class>[] value(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/interceptor/InterceptsRemoteCall.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/interceptor/InterceptsRemoteCall.java deleted file mode 100644 index 2ce16d7d819..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/interceptor/InterceptsRemoteCall.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api.interceptor; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * This annotation is used to indicate that a particular class should be - * used as an interceptor for a remote interface (e.g. RPC or REST - * interface). This works similarly to the {@link InterceptedCall} - * annotation but has the added benefit that it does not require the - * remote interface to be annotated. - * - * The class that is annotated should implement the {@link RemoteCallInterceptor} - * interface. - */ -@Documented -@Target({ ElementType.TYPE }) -@Retention(RetentionPolicy.RUNTIME) -public @interface InterceptsRemoteCall { - - /** - * The interceptor type(s) to use. Interceptor execution is guaranteed to be - * in declaration order. - */ - Class[] value(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/interceptor/LocalCallInterceptor.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/interceptor/LocalCallInterceptor.java deleted file mode 100644 index 37f027ccd09..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/interceptor/LocalCallInterceptor.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api.interceptor; - -/** - * Represents an interceptor for local/synchronous method calls. - * - * @author Christian Sadilek - * - * @param - * type of {@link CallContext} - */ -public interface LocalCallInterceptor extends CallInterceptor { - - /** - * Interposes on the execution of methods that should be intercepted. - * - * @param context - * the call context of the intercepted method, not null. - * - * @return the result of the intercepted method. - */ - public Object aroundInvoke(CallContext context); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/interceptor/RemoteCallContext.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/interceptor/RemoteCallContext.java deleted file mode 100644 index fd3a59f51ce..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/interceptor/RemoteCallContext.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api.interceptor; - -import org.jboss.errai.common.client.api.ErrorCallback; -import org.jboss.errai.common.client.api.RemoteCallback; - -/** - * Represents the context of an intercepted remote call. - * - * @author Christian Sadilek - */ -public abstract class RemoteCallContext extends CallContext { - private Object result; - - /** - * Returns the result of the intercepted remote call. - * - * @return intercepted method result, may be null. - */ - public Object getResult() { - return result; - } - - /** - * Sets the result of the intercepted remote call. When invoked from an - * {@link ErrorCallback} it will prevent the error from bubbling up and - * instead cause the {@link RemoteCallback} specified in the previous - * interceptor or at the actual remote call site to be invoked with the - * provided result. - * - * @param result - * The result to return to the caller of the intercepted method. - */ - public void setResult(final Object result) { - this.result = result; - } - - /** - * Proceeds to the next interceptor in the chain or with the execution of the - * intercepted method if all interceptors have been executed. - * - * @param callback - * The remote callback that receives the return value from the call. - * This callback is guaranteed to be invoked before the callback - * provided on the actual call site. Cannot be null. - */ - public abstract void proceed(RemoteCallback callback); - - /** - * Proceeds to the next interceptor in the chain or with the execution of the - * intercepted method if all interceptors have been executed. - * - * @param callback - * The remote callback that receives the return value from the call. - * This callback is guaranteed to be invoked before the callback - * provided on the actual call site. Cannot be null. - * - * @param errorCallback - * The error callback that receives transmission errors and - * exceptions thrown by the remote service. This error callback is - * guaranteed to be invoked before the error callback provided on the - * actual call site. Cannot be null. - */ - public abstract void proceed(RemoteCallback callback, ErrorCallback errorCallback); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/interceptor/RemoteCallInterceptor.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/interceptor/RemoteCallInterceptor.java deleted file mode 100644 index fe8b4523e00..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/interceptor/RemoteCallInterceptor.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api.interceptor; - -import org.jboss.errai.common.client.api.RemoteCallback; - -/** - * Represents an interceptor for asynchronous remote method calls. - * - * @author Christian Sadilek - * - * @param - * type of {@link CallContext} - */ -public interface RemoteCallInterceptor extends CallInterceptor { - - /** - * Interposes on the execution of remote method calls that should be intercepted. - *

- * Note that in contrast to local/synchronous method call interceptors, this method does not return a result as the - * actual remote call is executed asynchronously and the result is not available when this method returns. - *

- * To execute the actual remote call, invoke {@link RemoteCallContext#proceed()}. - *

- * To get access to the remote call's result, call {@link RemoteCallContext#proceed(RemoteCallback)} or - * {@link RemoteCallContext#proceed(RemoteCallback, ErrorCallback)}. - *

- * To change the result, call {@link RemoteCallContext#setResult(Object)}. - * - * @param context - * the call context of the intercepted method, not null. - */ - public void aroundInvoke(T context); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/package-info.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/package-info.java deleted file mode 100644 index ef12557baaa..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Parent package for public API shared by all modules of the Errai framework. - */ -package org.jboss.errai.common.client.api; diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/tasks/AsyncTask.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/tasks/AsyncTask.java deleted file mode 100644 index 995b06270e5..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/tasks/AsyncTask.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api.tasks; - -/** - * A handle representing an asynchronous task that has been submitted to the message bus. - */ -public interface AsyncTask { - - /** - * Prevents this task from being scheduled again, optionally interrupting the - * task if it is currently running. - * - * @param interrupt - * if true, and this task is presently being executed, - * {@link Thread#interrupt()} will be called on the thread currently - * executing this task. - */ - public void cancel(boolean interrupt); - - /** - * Sets the task that should be run after all executions of this task have - * completed. The supplied runnable is guaranteed to be invoked exactly once, - * even if this task has already completed or it has been cancelled. - * - * @param runnable - * the logic to execute when this task has completed all of its - * executions, either because it completed normally, by throwing an - * exception, or because it was cancelled by a call to - * {@link #cancel(boolean)}. - */ - public void setExitHandler(Runnable runnable); - - /** - * Returns true if {@link #cancel(boolean)} has been called on this task, - * whether it was called from user code or from within the framework because - * the task threw an exception. - * - * @return true if this task has been cancelled; false otherwise. - */ - public boolean isCancelled(); - - /** - * Returns true if this task is no longer scheduled to run, either because it executed - * (successfully or with an error) or {@link #cancel(boolean)} was called. - * - * @return true if this task is no longer scheduled to run. - */ - public boolean isFinished(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/tasks/ClientTaskManager.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/tasks/ClientTaskManager.java deleted file mode 100644 index 1102582d3b1..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/tasks/ClientTaskManager.java +++ /dev/null @@ -1,214 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api.tasks; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.core.client.RunAsyncCallback; -import com.google.gwt.user.client.Timer; -import org.jboss.errai.common.client.util.TimeUnit; - -/** - * The client-side implementation of {@link TaskManager}. - */ -public class ClientTaskManager implements TaskManager { - @Override - public void execute(final Runnable task) { - GWT.runAsync(new RunAsyncCallback() { - @Override - public void onFailure(final Throwable reason) { - GWT.log("failed async execution", reason); - } - - @Override - public void onSuccess() { - task.run(); - } - }); - } - - @Override - public AsyncTask scheduleRepeating(final TimeUnit unit, final int interval, final Runnable userTask) { - final TaskManagerTimer timer = new TaskManagerTimer(userTask); - timer.scheduleRepeating((int) unit.toMillis(interval)); - return timer.asyncTask; - } - - @Override - public AsyncTask schedule(final TimeUnit unit, final int interval, final Runnable userTask) { - final TaskManagerTimer timer = new TaskManagerTimer(userTask); - timer.schedule((int) unit.toMillis(interval)); - return timer.asyncTask; - } - - /** - * An AsyncTask implementation that is meant to be created and used by the - * {@link TaskManagerTimer}. - * - * @author Jonathan Fuerth - */ - private static class ClientAsyncTask implements Runnable, AsyncTask { - private final Runnable task; - private final TaskManagerTimer timer; - private Runnable exitHandler; - - /** - * True if and only if the task will never run again. - */ - private boolean finished; - private boolean isCancelled; - - /** - * Don't call this. Use {@link #create(Runnable, org.jboss.errai.common.client.api.tasks.ClientTaskManager.TaskManagerTimer)}. - * - * @param task - * @param timer - */ - private ClientAsyncTask(final Runnable task, final TaskManagerTimer timer) { - this.task = task; - this.timer = timer; - } - - @Override - public void run() { - try { - task.run(); - } catch (Throwable t) { - GWT.log("Async Task Execution Failed. Future executions (if any) are cancelled.", t); - timer.cancel(); - } - } - - /** - * Creates a new async task for the client, injecting the reference into - * {@code task} if it is an instance of {@link HasAsyncTaskRef}. - * - * @param task The code to execute. Not null. - * @param timer The timer that will execute class. Not null. - * @return A new AsyncTask that relates to {@code task}. - */ - public static ClientAsyncTask create(final Runnable task, final TaskManagerTimer timer) { - final ClientAsyncTask t = new ClientAsyncTask(task, timer); - if (task instanceof HasAsyncTaskRef) { - ((HasAsyncTaskRef) task).setAsyncTask(t); - } - return t; - } - - @Override - public void cancel(final boolean interrupt) { - timer.cancel(); - finishUp(); - } - - @Override - public void setExitHandler(final Runnable runnable) { - if (exitHandler != null) { - throw new IllegalStateException("Exit handler is already set to " + exitHandler); - } - this.exitHandler = runnable; - if (isFinished()) { - exitHandler.run(); - } - } - - @Override - public boolean isCancelled() { - return timer.isCancelled(); - } - - @Override - public boolean isFinished() { - return finished; - } - - public void finishUp() { - if (finished) { - throw new IllegalStateException("Already finished"); - } - finished = true; - if (exitHandler != null) { - exitHandler.run(); - } - } - } - - private enum SchedulingMode { ONE_TIME, REPEATING } - - /** - * A GWT Timer implementation that has a public flag indicating if - * {@link #cancel()})} has been called. - *

- * This Timer class only allows a single call to either {@link #schedule(int)} - * or {@link #scheduleRepeating(int)}. Further attempts to schedule the call - * will result in {@link IllegalStateException}. - * - * @author Jonathan Fuerth - */ - private final class TaskManagerTimer extends Timer { - - private SchedulingMode mode; - private final ClientAsyncTask asyncTask; - - TaskManagerTimer(final Runnable userTask) { - asyncTask = ClientAsyncTask.create(userTask, this); - } - - @Override - public void schedule(final int delayMillis) { - if (mode != null) { - throw new IllegalStateException("This timer has already been scheduled."); - } - mode = SchedulingMode.ONE_TIME; - super.schedule(delayMillis); - } - - @Override - public void scheduleRepeating(final int periodMillis) { - if (mode != null) { - throw new IllegalStateException("This timer has already been scheduled."); - } - mode = SchedulingMode.REPEATING; - super.scheduleRepeating(periodMillis); - } - - @Override - public void run() { - asyncTask.run(); - if (mode == SchedulingMode.ONE_TIME) { - asyncTask.finishUp(); - } - } - - @Override - public void cancel() { - super.cancel(); - asyncTask.isCancelled = true; - } - - public boolean isCancelled() { - return asyncTask.isCancelled; - } - } - - @Override - public void requestStop() { - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/tasks/HasAsyncTaskRef.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/tasks/HasAsyncTaskRef.java deleted file mode 100644 index 6d053d818f0..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/tasks/HasAsyncTaskRef.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api.tasks; - - -/** - * Errai schedulers that accept a Runnable and produce an {@link AsyncTask} will - * inject the AsyncTask instance into the runnable if it implements this - * interface. - * - * @see org.jboss.errai.common.client.api.tasks.ClientTaskManager - */ -public interface HasAsyncTaskRef extends Runnable { - - /** - * Called by Errai scheduler services when they receive this Runnable and - * before its run() method is called. - * - * @param task - * The companion AsyncTask instance that has been created for this - * runnable - */ - public void setAsyncTask(AsyncTask task); - - /** - * Returns the AsyncTask instance most recently set in - * {@link #setAsyncTask(AsyncTask)}, or null if {@code setAsyncTask()} has not - * been called yet. - */ - public AsyncTask getAsyncTask(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/tasks/TaskManager.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/tasks/TaskManager.java deleted file mode 100644 index d45cfb71da3..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/tasks/TaskManager.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api.tasks; - -import org.jboss.errai.common.client.util.TimeUnit; - -/** - * A deferred, delayed, and periodic scheduling facility that has - * implementations which behave the same on the client or the server. - *

- * Note that on the client, timer behaviour is somewhat dependant on browser - * behaviour. For example, the HTML 4 specification mandates that delays or - * intervals less than 10ms are silently increased to 10ms; HTML 5 lowers this - * minimum to 4ms. In addition, browsers such as Firefox and Chrome enforce a - * minimum timeout to 1000ms for pages in inactive tabs. - * - * @author Mike Brock - * @author Jonathan Fuerth > - * @author Christian Sadilek > - */ -public interface TaskManager { - - /** - * Schedules the given task for immediate execution, either on the calling - * thread or on the first available worker thread. - * - * @param task - * The task to execute. - * @throws IllegalStateException if {@link #requestStop()} has been called on this TaskManager. - */ - public void execute(Runnable task); - - /** - * Schedules the given task for repeated execution at the given rate. - *

- * Efforts are made to ensure repeating tasks begin execution at fixed time - * intervals, rather than having a fixed delay between the end of execution - * and the beginning of the next. For example, when a task that takes about 2 - * seconds to run is scheduled for repeating execution every 10 seconds, it - * will begin execution every 10 seconds. There will be about 8 seconds - * between the end of one execution and the beginning of the next. However, if - * a task that takes 20 seconds is scheduled to run every 10 seconds, it will - * not be re-executed while it is still running. In this case (where a task - * takes longer to execute than the specified interval), the task will be - * rescheduled for immediate execution upon completion. - * - * @param unit - * Specifies the units that {@code interval} is interpreted in. - * @param interval - * Amount of time to wait before starting each successive execution. - * @param task - * The task to execute repeatedly. - * @return A handle on the repeating task that allows it to be canceled. - * @throws IllegalStateException if {@link #requestStop()} has been called on this TaskManager. - */ - public AsyncTask scheduleRepeating(TimeUnit unit, int interval, Runnable task); - - /** - * Schedules the given task for execution at a later time. - * - * @param unit - * Specifies the units that {@code interval} is interpreted in. - * @param interval - * Amount of time to wait before starting each successive execution. - * @param task - * The task to execute repeatedly. - * @return A handle on the repeating task that allows it to be canceled. - * @throws IllegalStateException if {@link #requestStop()} has been called on this TaskManager. - */ - public AsyncTask schedule(TimeUnit unit, int interval, Runnable task); - - /** - * Prevents this task manager from beginning execution of all pending tasks. - * Does not terminate tasks that are currently executing. - *

- * Once this method has been called, any further method calls on this - * TaskManager will result in an IllegalStateException. - */ - public void requestStop(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/tasks/TaskManagerFactory.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/tasks/TaskManagerFactory.java deleted file mode 100644 index 73a9c235a21..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/tasks/TaskManagerFactory.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api.tasks; - -public class TaskManagerFactory { - - private static final Object lock = new Object(); - private static volatile TaskManagerProvider provider; - - public static TaskManager get() { - synchronized (lock) { - if (provider == null) { - _initForClient(); - } - return provider.get(); - } - - } - - private static void _initForClient() { - provider = new TaskManagerProvider() { - private ClientTaskManager taskManager = new ClientTaskManager(); - - public TaskManager get() { - return taskManager; - } - }; - } - - public static void setTaskManagerProvider(TaskManagerProvider p) { - synchronized (lock) { - if (provider == null) { - // Attempt to initialize the task manager twice. Will be ignored - provider = p; - } - } - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/tasks/TaskManagerProvider.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/tasks/TaskManagerProvider.java deleted file mode 100644 index 7196c4ff98c..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/api/tasks/TaskManagerProvider.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.api.tasks; - -public interface TaskManagerProvider { - public TaskManager get(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/dom/DOMUtil.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/dom/DOMUtil.java deleted file mode 100644 index 2528201f599..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/dom/DOMUtil.java +++ /dev/null @@ -1,486 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.dom; - -import java.util.Arrays; -import java.util.Iterator; -import java.util.NoSuchElementException; -import java.util.Optional; -import java.util.stream.Stream; - -import com.google.gwt.dom.client.Style; -import com.google.gwt.user.client.ui.IsWidget; -import com.google.gwt.user.client.ui.RootPanel; -import com.google.gwt.user.client.ui.Widget; -import elemental2.dom.CSSStyleDeclaration; -import elemental2.dom.DOMTokenList; -import elemental2.dom.Element; -import elemental2.dom.HTMLElement; -import elemental2.dom.Node; -import elemental2.dom.NodeList; - -/** - * Provides utility methods for interacting with the DOM. - * - * @deprecated Use Elemental 2 for new development - * - * @author Max Barkley - */ -@Deprecated -public abstract class DOMUtil { - private DOMUtil() {} - - /** - * @param element - * Must not be null. - * @return If the given element has any child elements, return an optional containing the first child element. - * Otherwise return an empty optional. - */ - public static Optional getFirstChildElement(final Element element) { - for (final Node child : nodeIterable(element.childNodes)) { - if (isElement(child)) { - return Optional.ofNullable((Element) child); - } - } - - return Optional.empty(); - } - - /** - * @param element - * Must not be null. - * @return If the given element has any child elements, return an optional containing the last child element. - * Otherwise return an empty optional. - */ - public static Optional getLastChildElement(final Element element) { - final NodeList children = element.childNodes; - for (int i = children.getLength()-1; i > -1; i--) { - if (isElement((Node) children.item(i))) { - return Optional.ofNullable((Element) children.item(i)); - } - } - - return Optional.empty(); - } - - /** - * @param node - * Must not be null. - * @return True iff the given node is an element. - */ - public static boolean isElement(final Node node) { - return node.nodeType == Node.ELEMENT_NODE; - } - - /** - * @param nodeList - * Must not be null. - * @return An iterable for the given node list. - */ - public static Iterable nodeIterable(final NodeList nodeList) { - return () -> DOMUtil.nodeIterator(nodeList); - } - - /** - * @param nodeList - * Must not be null. - * @return An iterator for the given node list. - */ - public static Iterator nodeIterator(final NodeList nodeList) { - return new Iterator() { - int index = 0; - - @Override - public boolean hasNext() { - return index < nodeList.getLength(); - } - - @Override - public Node next() { - if (hasNext()) { - return (Node) nodeList.item(index++); - } - else { - throw new NoSuchElementException(); - } - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - }; - } - - /** - * @param nodeList - * Must not be null. - * @return An iterable for the given node list that ignores non-element nodes. - */ - public static Iterable elementIterable(final NodeList nodeList) { - return () -> elementIterator(nodeList); - } - - /** - * @param nodeList - * Must not be null. - * @return An iterator for the given node list that ignores non-element nodes. - */ - public static Iterator elementIterator(final NodeList nodeList) { - return new Iterator() { - - int i = 0; - - @Override - public boolean hasNext() { - while (i < nodeList.getLength() && !isElement((Node) nodeList.item(i))) { - i++; - } - return i < nodeList.getLength(); - } - - @Override - public Element next() { - if (hasNext()) { - return (Element) nodeList.item(i++); - } - else { - throw new NoSuchElementException(); - } - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - }; - } - - /** - * Detaches an element from its parent. - * - * @param element - * Must not be null. - * @return True if calling this method detaches the given element from a parent node. False if there is no parent to - * be removed from. - */ - public static boolean removeFromParent(final Element element) { - if (element.parentElement != null) { - element.parentElement.removeChild(element); - - return true; - } - else { - return false; - } - } - - /** - * Detaches all children from a node. - * - * @param node - * Must not be null. - * @return True iff any children were detached by this call. - */ - public static boolean removeAllChildren(final Node node) { - final boolean hadChildren = node.lastChild != null; - while (node.lastChild != null) { - node.removeChild(node.lastChild); - } - - return hadChildren; - } - - /** - * Detaches all element children from a node. - * - * @param node - * Must not be null. - * @return True iff any element children were detached by this call. - */ - public static boolean removeAllElementChildren(final Node node) { - boolean elementRemoved = false; - for (final Element child : elementIterable(node.childNodes)) { - node.removeChild(child); - elementRemoved = true; - } - - return elementRemoved; - } - - /** - * Removes a CSS class from an element's class list. - * - * @param element - * Must not be null. - * @param className - * The name of a CSS class. Must not be null. - * @return True if the given class was removed from the given element. False if the given element did not have the - * given class as part of its class list. - */ - public static boolean removeCSSClass(final HTMLElement element, final String className) { - if (hasCSSClass(element, className)) { - element.classList.remove(className); - - return true; - } - else { - return false; - } - } - - /** - * Adds a CSS class to an element's class list. - * - * @param element - * Must not be null. - * @param className - * The name of a CSS class. Must not be null. - * @return True if the given class was added to the given element. False if the given element already had the - * given class as part of its class list. - */ - public static boolean addCSSClass(final HTMLElement element, final String className) { - if (hasCSSClass(element, className)) { - return false; - } - else { - element.classList.add(className); - - return true; - } - } - - /** - * @param element - * Must not be null. - * @param className - * The name of a CSS class. Must not be null. - * @return True iff the given element has the given CSS class as part of its class list. - */ - public static boolean hasCSSClass(final HTMLElement element, final String className) { - return element.classList.contains(className); - } - - /** - * @param tokenList - * Must not be null. - * @return A sequential, ordered {@link Stream} of tokens from the given {@link DOMTokenList}. - */ - public static Stream tokenStream(final DOMTokenList tokenList) { - return Stream - .iterate(0, n -> n + 1) - .limit(tokenList.getLength()) - .map(i -> tokenList.item(i)); - } - - /** - * @param styleDeclaration - * Must not be null. - * @return A stream of property names from the given style declaration. - */ - public static Stream cssPropertyNameStream(final CSSStyleDeclaration styleDeclaration) { - return Arrays - .stream(styleDeclaration.cssText != null - ? styleDeclaration.cssText.split(";") : new String[0]) - .map(style -> style.split(":", 2)[0].trim()) - .filter(propertyName -> !propertyName.isEmpty()); - } - - /** - * Appends the underlying {@link HTMLElement} of a {@link Widget} to another {@link HTMLElement}, in a way that does - * not break GWT Widget events. - * - * @param parent - * The parent element that is appended to. Must not be null. - * @param child - * The child Widget, whose underlying HTML element will be appended to the parent. Must not be null. - */ - public static void appendWidgetToElement(final HTMLElement parent, final IsWidget child) { - appendWidgetToElement(parent, child.asWidget()); - } - - /** - * Appends the underlying {@link HTMLElement} of a {@link Widget} to another {@link HTMLElement}, in a way that does - * not break GWT Widget events. - * - * @param parent - * The parent element that is appended to. Must not be null. - * @param child - * The child Widget, whose underlying HTML element will be appended to the parent. Must not be null. - */ - public static void appendWidgetToElement(final HTMLElement parent, final Widget child) { - if (child.isAttached()) { - child.removeFromParent(); - } - RootPanel.detachOnWindowClose(child); - parent.appendChild(nativeCast(child.getElement())); - onAttach(child); - } - - /** - *

- * Remove a {@link Widget} from its parent. Use this to undo calls to - * {@link #appendWidgetToElement(HTMLElement, IsWidget)}. - * - *

- * This works like calling {@code child.asWidget().removeFromParent()} except that if {@code child} is in the - * {@link RootPanel#isInDetachList(Widget) dettach list} its underlying HTML element will also be removed from its - * parent. - * - * @param child - * The child Widget, whose underlying HTML element will be removed from the parent. Must not be null. - */ - public static void removeFromParent(final IsWidget child) { - removeFromParent(child.asWidget()); - } - - /** - *

- * Remove a {@link Widget} from its parent. Use this to undo calls to - * {@link #appendWidgetToElement(HTMLElement, Widget)}. - * - *

- * This works like calling {@code child.removeFromParent()} except that if {@code child} is in the - * {@link RootPanel#isInDetachList(Widget) dettach list} its underlying HTML element will also be removed from its - * parent. - * - * @param child - * The child Widget, whose underlying HTML element will be removed from the parent. Must not be null. - */ - public static void removeFromParent(final Widget child) { - final boolean wasInDettachList = RootPanel.isInDetachList(child); - child.removeFromParent(); - if (wasInDettachList) { - child.getElement().removeFromParent(); - } - } - - /** - * Adds a unique enumerated CSS class to an element's class list removing all others - * in the enumerated {@link Style.HasCssName}. Other CSS classes not in the enumerated - * {@link Style.HasCssName} are preserved. - * - * @param element - * Must not be null. - * @param enumClass - * The {@link Style.HasCssName} class. Must not be null. - * @param style - * The enumerated {@link Style.HasCssName} element. Must not be null. - */ - public static > void addUniqueEnumStyleName(final HTMLElement element, - final Class enumClass, - final E style) { - removeEnumStyleNames(element, - enumClass); - addEnumStyleName(element, - style); - } - - /** - * Removes all of the enumerated CSS classes on an element's class list. - * - * @param element - * Must not be null. - * @param enumClass - * The {@link Style.HasCssName} class. Must not be null. - */ - public static > void removeEnumStyleNames(final HTMLElement element, - final Class enumClass) { - for (final Enum constant : enumClass.getEnumConstants()) { - final String cssClass = ((Style.HasCssName) constant).getCssName(); - - if (cssClass != null && !cssClass.isEmpty()) { - removeCSSClass(element, - cssClass); - } - } - } - - /** - * Adds an enumerated CSS class to an element's class list. - * - * @param element - * Must not be null. - * @param style - * The enumerated {@link Style.HasCssName} element. Must not be null. - */ - public static void addEnumStyleName(final HTMLElement element, - final E style) { - if (style != null && style.getCssName() != null && !style.getCssName().isEmpty()) { - addCSSClass(element, - style.getCssName()); - } - } - - /** - * Removes the enumerated CSS class from an element's class list. - * - * @param element - * Must not be null. - * @param style - * The enumerated {@link Style.HasCssName} element. Must not be null. - */ - public static void removeEnumStyleName(final HTMLElement element, - final E style) { - if (style != null && style.getCssName() != null && !style.getCssName().isEmpty()) { - removeCSSClass(element, - style.getCssName()); - } - } - - private static native void onAttach(Widget w)/*-{ - w.@com.google.gwt.user.client.ui.Widget::onAttach()(); - }-*/; - - private static native HTMLElement nativeCast(com.google.gwt.dom.client.Element gwtElement)/*-{ - return gwtElement; - }-*/; - - public static int getAbsoluteLeft(HTMLElement elem) { - int left = 0; - HTMLElement curr = elem; - // This intentionally excludes body which has a null offsetParent. - while (curr.offsetParent != null) { - left -= curr.scrollLeft; - curr = (HTMLElement) curr.parentNode; - } - while (elem != null) { - left += elem.offsetLeft; - elem = (HTMLElement) elem.offsetParent; - } - return left; - } - - public static int getAbsoluteTop(HTMLElement elem) { - int top = 0; - HTMLElement curr = elem; - // This intentionally excludes body which has a null offsetParent. - while (curr.offsetParent != null) { - top -= curr.scrollTop; - curr = (HTMLElement) curr.parentNode; - } - while (elem != null) { - top += elem.offsetTop; - elem = (HTMLElement) elem.offsetParent; - } - return top; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/dom/elemental2/Elemental2DomUtil.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/dom/elemental2/Elemental2DomUtil.java deleted file mode 100644 index 7c85c9252a4..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/dom/elemental2/Elemental2DomUtil.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.dom.elemental2; - -import com.google.gwt.user.client.ui.RootPanel; -import com.google.gwt.user.client.ui.Widget; -import elemental2.dom.HTMLElement; -import elemental2.dom.Node; -import jsinterop.base.Js; - -/** - * Provides utility methods for interacting with the DOM. - * @author Guilherme Carreiro - */ -public class Elemental2DomUtil { - - /** - * Detaches all element children from a node. - * @param node Must not be null. - * @return True iff any element children were detached by this call. - */ - public boolean removeAllElementChildren(final Node node) { - - final boolean hadChildren = node.lastChild != null; - - while (node.lastChild != null) { - node.removeChild(node.lastChild); - } - - return hadChildren; - } - - /** - * Appends the underlying {@link HTMLElement} of a {@link Widget} to another {@link HTMLElement}, - * in a way that does not break GWT Widget events. - * @param parent The parent element that is appended to. Must not be null. - * @param child The child Widget, whose underlying HTML element will be - * appended to the parent. Must not be null. - */ - public void appendWidgetToElement(final HTMLElement parent, final Widget child) { - - if (child.isAttached()) { - child.removeFromParent(); - } - - RootPanel.detachOnWindowClose(child); - - HTMLElement newChild = asHTMLElement(child.getElement()); - parent.appendChild(newChild); - - onAttach(child); - } - - /** - * Converts from {@link com.google.gwt.dom.client.Element} to {@link HTMLElement}. - * @param gwtElement The deprecated GWT Element - * @return The GWT Elemental2 HTMLElement - */ - public HTMLElement asHTMLElement(final com.google.gwt.dom.client.Element gwtElement) { - return Js.cast(gwtElement); - } - - native void onAttach(Widget w)/*-{ - w.@com.google.gwt.user.client.ui.Widget::onAttach()(); - }-*/; -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/framework/CallContextStatus.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/framework/CallContextStatus.java deleted file mode 100644 index 057f0bbdd4f..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/framework/CallContextStatus.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.framework; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * This class is used internally (in generated code for remote call interceptors) to store status information about an - * interceptor's call context. - * - * @author Christian Sadilek - */ -public class CallContextStatus { - private boolean proceeding = false; - private boolean interceptorChainStarted = false; - private final List> interceptors; - - public CallContextStatus(final Class... interceptors) { - this.interceptors = new ArrayList>(Arrays.asList(interceptors)); - } - - public void proceed() { - this.proceeding = true; - if (!interceptors.isEmpty()) { - if (interceptorChainStarted) { - interceptors.remove(0); - } - else { - interceptorChainStarted = true; - } - } - } - - public void setProceeding(final boolean proceeding) { - this.proceeding = proceeding; - } - - public boolean isProceeding() { - return proceeding; - } - - public Class getNextInterceptor() { - if (!interceptors.isEmpty()) { - return interceptors.get(0); - } - else { - return null; - } - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/framework/ClientCSRFTokenCache.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/framework/ClientCSRFTokenCache.java deleted file mode 100644 index ac0b5161384..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/framework/ClientCSRFTokenCache.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.framework; - -import jsinterop.annotations.JsOverlay; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsProperty; -import jsinterop.annotations.JsType; - -import static org.jboss.errai.common.client.framework.Constants.ERRAI_CSRF_TOKEN_VAR; - -/** - * - * @author Max Barkley - */ -@JsType(isNative = true) -public abstract class ClientCSRFTokenCache { - - private ClientCSRFTokenCache() { - } - - @JsProperty(namespace = JsPackage.GLOBAL, name = ERRAI_CSRF_TOKEN_VAR) - private static String erraiCSRFToken; - - @JsOverlay - public static boolean hasAssignedCSRFToken() { - return erraiCSRFToken != null; - } - - @JsOverlay - public static String getAssignedCSRFToken() { - return erraiCSRFToken; - } - - @JsOverlay - public static void setAssignedCSRFToken(final String newValue) { - erraiCSRFToken = newValue; - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/framework/Constants.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/framework/Constants.java deleted file mode 100644 index 2b1310ebcbc..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/framework/Constants.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.framework; - -/** - * - * @author Max Barkley - */ -public class Constants { - - public static final String ERRAI_CSRF_TOKEN_VAR = "erraiCSRFToken"; - public static final String ERRAI_CSRF_TOKEN_HEADER = "Errai-CSRF-Token"; - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/framework/ProxyFactory.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/framework/ProxyFactory.java deleted file mode 100644 index a42ade096e9..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/framework/ProxyFactory.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.framework; - -public interface ProxyFactory { - public T getRemoteProxy(Class proxyType); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/framework/ProxyProvider.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/framework/ProxyProvider.java deleted file mode 100644 index 61ef0ec8980..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/framework/ProxyProvider.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.framework; - -/** - * Provides instances of generated proxies. - * - * @author Christian Sadilek - */ -public interface ProxyProvider { - - /** - * Returns a new proxy instance. - * - * @return proxy, never null. - */ - public Object getProxy(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/framework/RemoteServiceProxyFactory.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/framework/RemoteServiceProxyFactory.java deleted file mode 100644 index 67d731ae580..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/framework/RemoteServiceProxyFactory.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.framework; - -import java.util.HashMap; -import java.util.Map; - -import org.jboss.errai.common.client.api.Assert; - -/** - * {@link ProxyFactory} storing {@link ProxyProvider}s for generated remote proxies. - * - * @author Christian Sadilek - */ -public class RemoteServiceProxyFactory implements ProxyFactory { - private static Map, ProxyProvider> remoteProxyProviders = new HashMap<>(); - - @Override - @SuppressWarnings({ "unchecked" }) - public T getRemoteProxy(final Class proxyType) { - Assert.notNull(proxyType); - - if (remoteProxyProviders.isEmpty()) { - throw new RuntimeException("There are no proxy providers registered.\n" - + "Hint: You may need to move this call to an @AfterInitialization method."); - } - - final ProxyProvider proxyProvider = remoteProxyProviders.get(proxyType); - if (proxyProvider == null) { - throw new RuntimeException("No proxy provider found for type [" + proxyType.getName() + "].\n" - + "Hint: Did you just add a new remote interface? The GWT generator may not have run in which case you should try:\n" - + "\t1. Touching an RPC interface that already has a proxy and refreshing (i.e. run `touch RemoteInterface.java`).\n" - + "\t2. Clear your Super Dev Mode cache (go to 127.0.0.1:9876 and click \"clear cache\").\n" - + "\t3. Run Super Dev Mode without incremental compilation."); - } - - final Object proxy = proxyProvider.getProxy(); - if (proxy == null) { - throw new RuntimeException("No proxy instance provided for: " + proxyType.getName()); - } - - return (T) proxy; - } - - public static void addRemoteProxy(final Class proxyType, final ProxyProvider proxyProvider) { - Assert.notNull(proxyType); - Assert.notNull(proxyProvider); - - remoteProxyProviders.put(proxyType, proxyProvider); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/framework/RpcBatch.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/framework/RpcBatch.java deleted file mode 100644 index 94733c6588d..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/framework/RpcBatch.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.framework; - -/** - * Represents a batch for remote procedure calls. It's used to accumulate remote calls that will get executed in a - * single server round trip when {@link #flush()} is called. - * - * @author Christian Sadilek - * - * @param - */ -public interface RpcBatch { - - /** - * Adds a request of type to the queue. - * - * @param request - * the request to send when {@link #flush()} is called. - */ - public void addRequest(T request); - - /** - * Sends all accumulated requests in a single server round trip. - */ - public void flush(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/framework/RpcStub.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/framework/RpcStub.java deleted file mode 100644 index 7d3bfcff324..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/framework/RpcStub.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.framework; - -import java.lang.annotation.Annotation; - -import org.jboss.errai.common.client.api.ErrorCallback; -import org.jboss.errai.common.client.api.RemoteCallback; - -public interface RpcStub { - public void setRemoteCallback(RemoteCallback callback); - - public void setErrorCallback(ErrorCallback callback); - - public void setQualifiers(Annotation[] annotations); - - public void setBatch(RpcBatch batch); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/logging/LoggingHandlerConfigurator.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/logging/LoggingHandlerConfigurator.java deleted file mode 100644 index 68e3f2f5680..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/logging/LoggingHandlerConfigurator.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.logging; - -import java.util.HashMap; -import java.util.Map; -import java.util.logging.Formatter; -import java.util.logging.Handler; -import java.util.logging.Level; -import java.util.logging.Logger; - -import com.google.gwt.core.client.EntryPoint; -import com.google.gwt.logging.client.HasWidgetsLogHandler; -import org.jboss.errai.common.client.logging.formatters.ErraiSimpleFormatter; -import org.jboss.errai.common.client.logging.handlers.ErraiConsoleLogHandler; -import org.jboss.errai.common.client.logging.handlers.ErraiDevelopmentModeLogHandler; -import org.jboss.errai.common.client.logging.handlers.ErraiLogHandler; -import org.jboss.errai.common.client.logging.handlers.ErraiSystemLogHandler; - -/** - * Initializes Errai log handlers, which are: - *

    - *
  • {@link ErraiSystemLogHandler}: Prints to terminal in Dev Mode.
  • - *
  • {@link ErraiConsoleLogHandler}: Logs to web console.
  • - *
  • {@link ErraiDevelopmentModeLogHandler}: Logs to Dev Mode window.
  • - *
- * - * By default these handlers use the {@link ErraiSimpleFormatter} to format - * output. - * - * @author Max Barkley - */ -public class LoggingHandlerConfigurator implements EntryPoint { - - private final Map, Handler> handlers = new HashMap<>(); - private static LoggingHandlerConfigurator instance; - - @Override - public void onModuleLoad() { - final Logger logger = Logger.getLogger(""); - - // FIXME temporary workaround for - // https://groups.google.com/forum/#!topic/google-web-toolkit/Sd9P0UjUyRA - - // We had to remove for GWT 2.7 compatibility but don't want to annoy our - // users on older GWT versions with the pop-up window or force them to - // disable the logger themselves. - final Handler[] logHandlers = logger.getHandlers(); - if (logHandlers != null) { - for (final Handler logHandler : logHandlers) { - if (logHandler instanceof HasWidgetsLogHandler) { - logger.removeHandler(logHandler); - ((HasWidgetsLogHandler)logHandler).clear(); - } - } - } - - handlers.put(ErraiSystemLogHandler.class, new ErraiSystemLogHandler()); - logger.addHandler(handlers.get(ErraiSystemLogHandler.class)); - - handlers.put(ErraiConsoleLogHandler.class, new ErraiConsoleLogHandler()); - logger.addHandler(handlers.get(ErraiConsoleLogHandler.class)); - - handlers.put(ErraiDevelopmentModeLogHandler.class, new ErraiDevelopmentModeLogHandler()); - logger.addHandler(handlers.get(ErraiDevelopmentModeLogHandler.class)); - - instance = this; - } - - /** - * @return The single instance of {@link LoggingHandlerConfigurator}. - */ - public static LoggingHandlerConfigurator get() { - return instance; - } - - /** - * Get the top-level Errai log handlers. This could be useful if you wish to - * change the {@link Level} or {@link Formatter} of a handler. - * - * @param handlerType - * The type of an {@link ErraiLogHandler}. - * @return The active {@link Handler} of the requested type. - */ - @SuppressWarnings("unchecked") - public H getHandler(final Class handlerType) { - return (H) handlers.get(handlerType); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/logging/formatters/ErraiSimpleFormatter.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/logging/formatters/ErraiSimpleFormatter.java deleted file mode 100644 index 7d4ed628d88..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/logging/formatters/ErraiSimpleFormatter.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.logging.formatters; - -import java.util.Date; -import java.util.logging.Formatter; -import java.util.logging.LogRecord; -import java.util.logging.SimpleFormatter; - -import org.jboss.errai.common.client.logging.util.StringFormat; - -/** - * Emulates the behaviour of {@link SimpleFormatter}, but the format string is - * stored as a JSNI value. - * - * @see ErraiSimpleFormatter#setSimpleFormatString(String) - * @author Max Barkley - */ -public class ErraiSimpleFormatter extends Formatter { - - public static final String defaultFormat = "%1$tH:%1$tM:%1$tS %4$s [%3$s] %5$s"; - - private Date date; - private String customFormat; - - public ErraiSimpleFormatter() { - date = new Date(); - } - - public ErraiSimpleFormatter(String customFormat) { - this(); - this.customFormat = customFormat; - } - - - @Override - public synchronized String format(LogRecord record) { - date.setTime(record.getMillis()); - // Get simple class name of logger - String name = record.getLoggerName().substring(Math.max(record.getLoggerName().lastIndexOf(".") + 1, 0)); - Object thrown = (record.getThrown() != null) ? record.getThrown() : ""; - - return StringFormat.format(getSimpleFormatString(customFormat), date, record.getLoggerName(), name, record - .getLevel().getName(), record.getMessage(), thrown); - } - - /** - * Set the value for the format string used by all - * {@link ErraiSimpleFormatter} instances. The provided format string is - * called with {@link StringFormat} like so: - * - *
-   *    {@code StringFormat.format(formatString, date, fullLoggerName, simpleLoggerName, level, throwable)}
-   * 
- * - * The parameters are as follows: - *
    - *
  • {@code formatString}: the format string (see - * {@link StringFormat#format(String, Object...)} for details).
  • - *
  • {@code date}: the log date, either a {@link Long} or {@code Date}.
  • - *
  • {@code fullLoggerName}: the full name of the logger.
  • - *
  • {@code simpleLoggerName}: a substring of the full logger name, starting - * after the last '.', or the full name if no '.' occurs (i.e. "a.b.c" --> - * "c", "abc" --> "abc").
  • - *
  • {@code level}: the level of the this log entry (i.e. TRACE, DEBUG, - * INFO, WARN, ERROR).
  • - *
  • {@code throwable}: the {@code throwable} accompanying this log entry, - * or {@code null} if none provided.
  • - *
- * The call to {@link StringFormat#format(String, Object...)} is designed to - * mimic the call to {@link String#format(String, Object...)} in - * {@link SimpleFormatter}, however there are some differences. Please see - * {@link StringFormat#format(String, Object...)} for details. - * - * @param format - * The format string for used by all {@link ErraiSimpleFormatter} instances. - */ - public static native void setSimpleFormatString(String format) /*-{ - if (format == null) { - $wnd.erraiSimpleFormatString = null; - } - else { - $wnd.erraiSimpleFormatString = format; - } - }-*/; - - /** - * @return The global format string. - * @see ErraiSimpleFormatter#setSimpleFormatString(String) - */ - public static native String getSimpleFormatString() /*-{ - if ($wnd.erraiSimpleFormatString === null || $wnd.erraiSimpleFormatString === undefined - || $wnd.erraiSimpleFormatString.length === 0) { - return ""; - } - else { - return $wnd.erraiSimpleFormatString; - } - }-*/; - - /** - * @param customFormat - * the custom format provided when creating this formatter (see - * {@link ErraiSimpleFormatter#ErraiSimpleFormatter(String)}) - * @return The custom format string, if provided, otherwise the global format - * string, or default format if no global format has been set. - */ - public String getSimpleFormatString(String customFormat) { - if (customFormat != null) { - return customFormat; - } - - String retVal = getSimpleFormatString(); - return (!retVal.equals("")) ? retVal : defaultFormat; - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/logging/handlers/ErraiConsoleLogHandler.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/logging/handlers/ErraiConsoleLogHandler.java deleted file mode 100644 index 67f8feb27d2..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/logging/handlers/ErraiConsoleLogHandler.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.logging.handlers; - -import java.util.List; -import java.util.logging.Formatter; -import java.util.logging.Level; -import java.util.logging.LogRecord; - -import com.google.gwt.logging.client.ConsoleLogHandler; -import org.jboss.errai.common.client.logging.formatters.ErraiSimpleFormatter; -import org.jboss.errai.common.client.logging.util.Console; - -import static org.jboss.errai.common.client.logging.util.StackTraceFormatter.getStackTraces; - -/** - * An extension of {@link ConsoleLogHandler} that uses a given {@link Formatter} and prints stack traces that Google - * Chrome can translate with source maps. - * - * @author Max Barkley - */ -public class ErraiConsoleLogHandler extends ConsoleLogHandler implements ErraiLogHandler { - - @FunctionalInterface - private static interface LevelLogger { - - void log(String msg); - - } - - /* - * Workaround to so that superlcass does not overwrite log level - */ - private boolean init = false; - - public ErraiConsoleLogHandler(final Formatter formatter) { - setFormatter(formatter); - init = true; - } - - public ErraiConsoleLogHandler() { - this(new ErraiSimpleFormatter()); - } - - @Override - public void publish(final LogRecord record) { - if (!isLoggable(record)) { - return; - } - String msg = getFormatter().format(record); - int val = record.getLevel().intValue(); - if (val >= Level.SEVERE.intValue()) { - error(msg, record); - } else if (val >= Level.WARNING.intValue()) { - warn(msg, record); - } else if (val >= Level.INFO.intValue()) { - info(msg, record); - } else { - log(msg, record); - } - } - - private void log(String msg, LogRecord record) { - logWith(msg, record, m -> Console.log(m)); - } - - private void info(String msg, LogRecord record) { - logWith(msg, record, m -> Console.info(m)); - } - - private void warn(String msg, LogRecord record) { - logWith(msg, record, m -> Console.warn(m)); - } - - private void error(final String msg, final LogRecord record) { - logWith(msg, record, m -> Console.error(m)); - } - - private void logWith(final String msg, final LogRecord record, final LevelLogger logger) { - logger.log(msg); - maybeLogException(record, logger); - } - - private void maybeLogException(final LogRecord record, final LevelLogger logger) { - if (record.getThrown() != null) { - final List stackTraces = getStackTraces(record.getThrown()); - for (final String stackTrace : stackTraces) { - logger.log(stackTrace); - } - } - } - - @Override - public boolean isEnabled() { - return !getLevel().equals(Level.OFF); - } - - @Override - public void setLevel(Level newLevel) { - if (init) - staticSetLevel(newLevel.getName()); - } - - @Override - public Level getLevel() { - return Level.parse(staticGetLevel()); - } - - public static native void staticSetLevel(String newLevel) /*-{ - $wnd.erraiConsoleLogHandlerLevel = newLevel; - }-*/; - - public static native String staticGetLevel() /*-{ - if ($wnd.erraiConsoleLogHandlerLevel === undefined) { - return "ALL"; - } else { - return $wnd.erraiConsoleLogHandlerLevel; - } - }-*/; -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/logging/handlers/ErraiDevelopmentModeLogHandler.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/logging/handlers/ErraiDevelopmentModeLogHandler.java deleted file mode 100644 index f2533ce6d8c..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/logging/handlers/ErraiDevelopmentModeLogHandler.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.logging.handlers; - -import java.util.logging.Formatter; -import java.util.logging.Level; - -import com.google.gwt.logging.client.DevelopmentModeLogHandler; -import org.jboss.errai.common.client.logging.formatters.ErraiSimpleFormatter; - -/** - * An extension of {@link DevelopmentModeLogHandler} that uses a given {@link Formatter}. - * - * @author Max Barkley - */ -public class ErraiDevelopmentModeLogHandler extends DevelopmentModeLogHandler implements ErraiLogHandler { - - /* - * Workaround to so that superlcass does not overwrite log level - */ - private boolean init = false; - - public ErraiDevelopmentModeLogHandler(final Formatter formatter) { - setFormatter(formatter); - init = true; - } - - public ErraiDevelopmentModeLogHandler() { - this(new ErraiSimpleFormatter()); - } - - @Override - public boolean isEnabled() { - return !getLevel().equals(Level.OFF); - } - - @Override - public void setLevel(Level newLevel) { - if (init) - staticSetLevel(newLevel.getName()); - } - - @Override - public Level getLevel() { - return Level.parse(staticGetLevel()); - } - - public static native void staticSetLevel(String newLevel) /*-{ - $wnd.erraiDevelopmentModeLogHandlerLevel = newLevel; - }-*/; - - public static native String staticGetLevel() /*-{ - if ($wnd.erraiDevelopmentModeLogHandlerLevel === undefined) { - return "ALL"; - } else { - return $wnd.erraiDevelopmentModeLogHandlerLevel; - } - }-*/; -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/logging/handlers/ErraiLogHandler.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/logging/handlers/ErraiLogHandler.java deleted file mode 100644 index d401f561173..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/logging/handlers/ErraiLogHandler.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.logging.handlers; - -import java.util.logging.Level; - - -public interface ErraiLogHandler { - - public boolean isEnabled(); - - public void setLevel(Level level); - - public Level getLevel(); - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/logging/handlers/ErraiSystemLogHandler.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/logging/handlers/ErraiSystemLogHandler.java deleted file mode 100644 index 90cdc25d796..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/logging/handlers/ErraiSystemLogHandler.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.logging.handlers; - -import java.util.logging.Formatter; -import java.util.logging.Level; - -import com.google.gwt.logging.client.SystemLogHandler; -import org.jboss.errai.common.client.logging.formatters.ErraiSimpleFormatter; - -/** - * An extension of {@link SystemLogHandler} that uses a given {@link Formatter}. - * - * @author Max Barkley - */ -public class ErraiSystemLogHandler extends SystemLogHandler implements ErraiLogHandler { - - /* - * Workaround to so that superlcass does not overwrite log level - */ - private boolean init = false; - - private ErraiSystemLogHandler(final Formatter formatter) { - setFormatter(formatter); - init = true; - } - - public ErraiSystemLogHandler() { - this(new ErraiSimpleFormatter()); - } - - @Override - public boolean isEnabled() { - return !getLevel().equals(Level.OFF); - } - - @Override - public void setLevel(Level newLevel) { - if (init) - staticSetLevel(newLevel.getName()); - } - - @Override - public Level getLevel() { - return Level.parse(staticGetLevel()); - } - - public static native void staticSetLevel(String newLevel) /*-{ - $wnd.erraiSystemLogHandlerLevel = newLevel; - }-*/; - - public static native String staticGetLevel() /*-{ - if ($wnd.erraiSystemLogHandlerLevel === undefined) { - return "ALL"; - } else { - return $wnd.erraiSystemLogHandlerLevel; - } - }-*/; - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/logging/util/Console.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/logging/util/Console.java deleted file mode 100644 index f2df7736644..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/logging/util/Console.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.logging.util; - -import jsinterop.annotations.JsType; - -/** - * Provides direct access to the logging methods on the browser window's console. - * - * @author Max Barkley - */ -@JsType(isNative = true, namespace = "window", name = "console") -public abstract class Console { - - private Console() {} - - public static native void log(String obj); - public static native void info(String obj); - public static native void warn(String obj); - public static native void error(String obj); - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/logging/util/ReflectableJSO.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/logging/util/ReflectableJSO.java deleted file mode 100644 index c7067f01524..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/logging/util/ReflectableJSO.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.jboss.errai.common.client.logging.util; - -import com.google.gwt.core.client.ScriptInjector; -import jsinterop.annotations.JsOverlay; -import jsinterop.annotations.JsType; - -/** - * A utility class for accessing arbitrary properties of native Javascript types. - * - * @author Max Barkley - */ -@JsType(isNative = true, namespace = "org.jboss.errai") -public class ReflectableJSO { - - private ReflectableJSO(final Object wrapped) {} - - @JsOverlay - public static final ReflectableJSO create(final Object wrapped) { - ScriptInjector - .fromString( - "org = {" - + "'jboss' : {" - + "'errai' : {" - + "'ReflectableJSO' : function(wrapped) {" - + "this.get = function(name) {" - + "return wrapped[name];" - + "};" - + "this.set = function(name, value) {" - + "wrapped[name] = value;" - + "};" - + "this.properties = function() {" - + "var retVal = [];" - + "for (key in wrapped) {" - + "retVal.push(key);" - + "}" - + "return retVal;" - + "};" - + "this.unwrap = function() {" - + "return wrapped;" - + "}" - + "}" - + "}" - + "}" - + "};") - .setWindow(ScriptInjector.TOP_WINDOW).setRemoveTag(true).inject(); - return new ReflectableJSO(wrapped); - } - - @JsOverlay - public final boolean hasProperty(final String name) { - return get(name) != null; - } - - public final native Object get(final String name); - - public final native void set(final String name, final Object value); - - public final native String[] properties(); - - public final native Object unwrap(); -} \ No newline at end of file diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/logging/util/StackTraceFormatter.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/logging/util/StackTraceFormatter.java deleted file mode 100644 index 692b70e13ea..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/logging/util/StackTraceFormatter.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.jboss.errai.common.client.logging.util; - -import java.io.OutputStream; -import java.io.PrintStream; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; - -/** - * Formats stack traces so that the Google Chrome web console will translate the line numbers with source maps. - * - * @author Max Barkley - */ -public class StackTraceFormatter { - - private StackTraceFormatter() {} - - public static List getStackTraces(final Throwable error) { - final List causes = new ArrayList<>(); - Throwable cur = error.getCause(); - while (cur != null) { - causes.add(cur); - cur = cur.getCause(); - } - - final List stacks = new ArrayList<>(); - - final String errorStack = getNativeStack(error); - if (errorStack != null) { - // Important: As late as Google Chrome 48, only stack traces starting with 'Error: ' get translated. - stacks.add("Error: " + getNameAndMessage(error) + errorStack); - for (final Throwable t : causes) { - final String rawStack = getNativeStack(t); - stacks.add("Error caused by: " + getNameAndMessage(t) + rawStack); - } - } - else { - stacks.add(getEmulatedStack(error)); - } - - return stacks; - } - - private static String getEmulatedStack(final Throwable t) { - String stack; - final StringBuilder builder = new StringBuilder(); - t.printStackTrace(new PrintStream((OutputStream) null) { - @Override - public void println(final String x) { - builder.append(x).append('\n'); - } - }); - - stack = builder.toString(); - return stack; - } - - private static String getNativeStack(final Throwable t) { - return maybeGetJSError(t) - .map(jsError -> { - String stack = (String) ReflectableJSO.create(jsError).get("stack"); - - stack = stack.substring(stack.indexOf('\n')); - return stack; - }).orElse(null); - } - - private static Optional maybeGetJSError( final Throwable t ) { - final ReflectableJSO reflectable = ReflectableJSO.create(t); - return Arrays - .stream(reflectable.properties()) - .map(key -> reflectable.get(key)) - .filter(obj -> obj != null) - .map(prop -> ReflectableJSO.create(prop)) - .filter(prop -> prop.get("name") != null && prop.get("message") != null) - .map(prop -> prop.unwrap()) - .findFirst(); - } - - private static String getNameAndMessage(final Throwable t) { - return t.getClass().getSimpleName() + ": " + t.getMessage(); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/logging/util/StringFormat.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/logging/util/StringFormat.java deleted file mode 100644 index cc9864a48e4..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/logging/util/StringFormat.java +++ /dev/null @@ -1,437 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.logging.util; - -import java.util.Arrays; -import java.util.Date; - -import com.google.gwt.i18n.client.LocaleInfo; -import com.google.gwt.i18n.client.NumberFormat; -import com.google.gwt.i18n.client.TimeZone; -import com.google.gwt.regexp.shared.MatchResult; -import com.google.gwt.regexp.shared.RegExp; -import com.google.gwt.user.datepicker.client.CalendarUtil; - -/** - * A utility class for replacing the {@link String#format(String, Object...)} method. - * - * @author Max Barkley - */ -public class StringFormat { - - private static enum Conversion { - bool, hexStr, str, uniChar, decInt, octInt, hexInt, sciInt, decNum, compNum, hexNum, date, escLit, line - } - - private static final String argIndex = "(?:(\\d+)\\$)?"; - private static final String flags = "([-#+ 0,(]*)?"; - private static final String width = "(\\d+)?"; - private static final String prec = "(?:\\.(\\d+))?"; - private static final String dateSuffix = "([HIklMSLNpzZsQBbhAaCYyjmdeRTrDFc])?"; - // Includes date/time suffix - private static final String conv = "([bBhHsScCdoxXeEfgGaA%n]|(?:[tT]" + dateSuffix + "))"; - - private static RegExp convPattern = RegExp.compile("%" + argIndex + flags + width + prec + conv); - - /** - * This method emulates {@link String#format(String, Object...)} with some - * notable differences: - *
    - *
  • flags are unsupported (and are silently ignored)
  • - *
  • the '{@code a}' and '{@code A}' conversions are unsupported
  • - *
  • the other scientific notation flags use {@link NumberFormat} and thus - * produce slightly different output
  • - *
- * - * @param format - * The format string. - * @param args - * The values available for format string conversions. - * @return A formatted string, similar to the result of calling - * {@link String#format(String, Object...)} with {@code format} and - * {@code args}. - * @see String#format(String, Object...) - */ - public static String format(String format, Object... args) { - StringBuffer buffer = new StringBuffer(format.length()); - final String originalFormat = format; - int count = 0; - - // Special case: user does StringFormat.format("...", null) - if (args == null) { - args = new Object[] {null}; - } - - int i = 0; - while (i < format.length()) { - if (format.charAt(i) == '%') { - final String subStr = format.substring(i); - final MatchResult match = convPattern.exec(subStr); - if (match == null || match.getIndex() != 0) { - throw new IllegalArgumentException("Bad conversion at index " + i + " in format String: " + format); - } - - if (match.getGroup(2) != null && !match.getGroup(2).equals("")) { - throw new UnsupportedOperationException("Flags are not yet supported in this implementation."); - } - - // TODO: check preconditions and possibly throw IllegalFormatException - final Object arg; - final int width; - final int prec; - final String suffix; - final Conversion conv = getConversion(match.getGroup(5).charAt(0)); - final boolean autoIndexed = match.getGroup(1) == null || match.getGroup(1).equals(""); - - if (conv.equals(Conversion.escLit) || conv.equals(Conversion.line)) { - arg = null; - } - else if (autoIndexed) { - arg = args[count]; - } - else { - arg = args[Integer.valueOf(match.getGroup(1)) - 1]; - } - - if (match.getGroup(3) == null || match.getGroup(3).equals("")) { - width = 0; - } - else { - width = Integer.valueOf(match.getGroup(3)); - } - - if (match.getGroup(4) == null || match.getGroup(4).equals("")) { - prec = Integer.MAX_VALUE; - } - else { - prec = Integer.valueOf(match.getGroup(4)); - } - - if (match.getGroup(6) == null || match.getGroup(6).equals("")) { - suffix = ""; - } - else { - suffix = match.getGroup(6); - } - - final boolean upper = match.getGroup(5).toUpperCase().equals(match.getGroup(5)); - String replacement; - try { - replacement = buildReplacement(conv, upper, width, prec, suffix, arg); - } - catch (Exception e) { - throw new IllegalArgumentException("Error processing substitution " + (count + 1) + ".\nFormat: " - + originalFormat + "\nArgs: " + Arrays.toString(args), e); - } - - buffer.append(replacement); - i += match.getGroup(0).length(); - - // Auto-index is incremented for non-explicitly indexed conversions - if (autoIndexed) - count += 1; - } - else { - buffer.append(format.charAt(i++)); - } - } - - return buffer.toString(); - } - - private static String buildReplacement(Conversion conv, boolean upper, int width, int prec, String suffix, Object arg) { - String res = null; - switch (conv) { - case bool: - if (arg instanceof Boolean) { - if ((Boolean) arg) { - res = "true"; - } - else { - res = "false"; - } - } else if (arg != null) { - res = "true"; - } else { - res = "false"; - } - break; - case date: - if (suffix == null || suffix.length() != 1) - throw new IllegalArgumentException("Must provide suffix with date conversion."); - if (arg instanceof Long) - arg = new Date((Long) arg); - res = processDate((Date) arg, upper, suffix.charAt(0)); - break; - case decInt: - res = String.valueOf((Integer) arg); - break; - case decNum: - if (arg instanceof Float) { - res = String.valueOf((Float) arg); - } - else { - res = String.valueOf((Double) arg); - } - break; - case hexInt: - res = Integer.toHexString((Integer) arg); - break; - case hexStr: - if (arg == null) - res = "null"; - else - res = Integer.toHexString(arg.hashCode()); - break; - case octInt: - res = Integer.toOctalString((Integer) arg); - break; - case str: - if (arg == null) - res = "null"; - else - res = arg.toString(); - break; - case uniChar: - if (arg instanceof Integer) - arg = Character.valueOf((char) ((Integer) arg).intValue()); - res = Character.toString((Character) arg); - break; - case compNum: - case sciInt: - if (arg instanceof Float) { - arg = Double.valueOf((Float) arg); - } - if (Integer.MAX_VALUE == prec) - prec = 6; - final StringBuilder formatString = new StringBuilder(prec+5); - formatString.append("0."); - for (int i = 0; i < prec; i++) - formatString.append('0'); - formatString.append("E00"); - - res = NumberFormat.getFormat(formatString.toString()).format((Double) arg); - if (!upper) - res = res.toLowerCase(); - - return padOrTrunc(res, width, Integer.MAX_VALUE); - // TODO - case hexNum: - throw new UnsupportedOperationException(); - case line: - return "\n"; - case escLit: - return "%"; - } - res = padOrTrunc(res, width, prec); - if (upper) - return res.toUpperCase(); - else - return res; - } - - @SuppressWarnings("deprecation") - private static String processDate(Date date, boolean upper, char suffix) { - String retVal = null; - switch (suffix) { - case 'k': - retVal = String.valueOf(date.getHours()); - break; - case 'H': - retVal = String.valueOf(padInt(date.getHours(), 2)); - break; - case 'l': - retVal = String.valueOf(date.getHours() % 12); - break; - case 'I': - retVal = String.valueOf(padInt(date.getHours() % 12, 2)); - break; - case 'M': - retVal = String.valueOf(padInt(date.getMinutes(), 2)); - break; - case 'S': - retVal = String.valueOf(padInt(date.getSeconds(), 2)); - break; - case 'L': - retVal = String.valueOf(padInt((int) (date.getTime() % 1000), 3)); - break; - case 'N': - retVal = String.valueOf(padInt((int) ((date.getTime() % 1000) * 1000000), 9)); - break; - case 'p': - retVal = LocaleInfo.getCurrentLocale().getDateTimeFormatInfo().ampms()[date.getHours() / 12]; - break; - case 's': - retVal = String.valueOf(date.getTime() / 1000); - break; - case 'Q': - retVal = String.valueOf(date.getTime()); - break; - case 'C': - retVal = String.valueOf(padInt((date.getYear() + 1900) / 100, 2)); - break; - case 'Y': - retVal = String.valueOf(padInt(date.getYear() + 1900, 4)); - break; - case 'y': - retVal = String.valueOf(padInt(date.getYear() % 100, 2)); - break; - case 'j': - final Date lastYear = new Date(date.getTime()); - lastYear.setYear(date.getYear() - 1); - lastYear.setMonth(11); - lastYear.setDate(31); - - retVal = String.valueOf(padInt(CalendarUtil.getDaysBetween(lastYear, date), 3)); - break; - case 'z': - retVal = TimeZone.createTimeZone(date.getTimezoneOffset()).getRFCTimeZoneString(date); - break; - case 'm': - retVal = String.valueOf(padInt(date.getMonth() + 1, 2)); - break; - case 'd': - retVal = String.valueOf(padInt(date.getDate(), 2)); - break; - case 'e': - retVal = String.valueOf(date.getDate()); - break; - case 'R': - retVal = processDate(date, false, 'H') + ":" + processDate(date, false, 'M'); - break; - case 'T': - retVal = processDate(date, false, 'R') + ":" + processDate(date, false, 'S'); - break; - case 'r': - retVal = processDate(date, false, 'I') + ":" + processDate(date, false, 'M') + ":" + processDate(date, upper, 'S') - + " " + processDate(date, true, 'p'); - break; - case 'D': - retVal = processDate(date, false, 'm') + "/" + processDate(date, false, 'd') + "/" + processDate(date, false, 'y'); - break; - case 'F': - retVal = processDate(date, false, 'Y') + "-" + processDate(date, false, 'm') + "-" + processDate(date, false, 'd'); - break; - case 'Z': - retVal = TimeZone.createTimeZone(date.getTimezoneOffset()).getShortName(date); - break; - case 'B': - retVal = LocaleInfo.getCurrentLocale().getDateTimeFormatInfo().monthsFull()[date.getMonth()]; - break; - case 'b': - case 'h': - retVal = LocaleInfo.getCurrentLocale().getDateTimeFormatInfo().monthsShort()[date.getMonth()]; - break; - case 'A': - retVal = LocaleInfo.getCurrentLocale().getDateTimeFormatInfo().weekdaysFull()[date.getDay()]; - break; - case 'a': - retVal = LocaleInfo.getCurrentLocale().getDateTimeFormatInfo().weekdaysShort()[date.getDay()]; - break; - case 'c': - retVal = processDate(date, false, 'a') + " " + processDate(date, false, 'b') + " " + processDate(date, false, 'd') - + " " + processDate(date, false, 'T') + " " + processDate(date, false, 'Z') + " " - + processDate(date, false, 'Y'); - break; - default: - throw new IllegalArgumentException("Invalid date suffix: " + suffix); - } - - if (upper) - return retVal.toUpperCase(); - else - return retVal; - } - - private static String padInt(int num, int width) { - final StringBuilder builder = new StringBuilder(width); - // num %= (int) Math.pow(10, width); - for (int d = width - 1; d >= 0; d--) { - int div = (int) Math.pow(10, d); - builder.append(num / div); - num %= div; - } - - return builder.toString(); - } - - private static String padOrTrunc(String res, int min, int max) { - if (res.length() < min) { - final StringBuilder builder = new StringBuilder(min); - for (int i = 0; i < min - res.length(); i++) { - builder.append(" "); - } - builder.append(res); - return builder.toString(); - } - else if (res.length() > max) { - return res.substring(0, max); - } - else { - return res; - } - } - - private static Conversion getConversion(char c) { - switch (c) { - case 'b': - case 'B': - return Conversion.bool; - case 'h': - case 'H': - return Conversion.hexStr; - case 's': - case 'S': - return Conversion.str; - case 'c': - case 'C': - return Conversion.uniChar; - case 'd': - return Conversion.decInt; - case 'o': - return Conversion.octInt; - case 'x': - case 'X': - return Conversion.hexInt; - case 'e': - case 'E': - return Conversion.sciInt; - case 'f': - return Conversion.decNum; - case 'g': - case 'G': - return Conversion.compNum; - case 'a': - case 'A': - return Conversion.hexNum; - case 'T': - case 't': - return Conversion.date; - case '%': - return Conversion.escLit; - case 'n': - return Conversion.line; - default: - throw new IllegalArgumentException(c + " is not a valid conversion character."); - } - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/package-info.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/package-info.java deleted file mode 100644 index b914d22090d..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Parent package for all API shared by all modules of the Errai framework. - *

- * The user-facing part of the shared API is in the {@link org.jboss.errai.common.client.api} - * package; everything else is internal to the framework: intended for use by Errai modules - * and extensions, but not by end-user applications. - */ -package org.jboss.errai.common.client; diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/protocols/MessageParts.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/protocols/MessageParts.java deleted file mode 100644 index bebafdb3f70..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/protocols/MessageParts.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.protocols; - -/** - * The parts comprising the core messaging protocol used by ErraiBus. - *

- * As a general rule, you should avoid using the words reserved by this protocol. - */ -public enum MessageParts { - /** - * Specifies the specific command within the service that is being requested. This is an optional element, - * and is not required for signal-only services. However it's use is encouraged for building multi-command - * services. - */ - CommandType, - - /** - * Specifies a subject being referenced for use in an command. This should not be confused with {@link #ToSubject}, - * which is used for message routing. - */ - Subject, - - /** - * A list of subjects. - */ - SubjectsList, - - /** - * - * @since 3.0 - */ - RemoteServices, - - /** - * A list of capabilities (comma-seperate string) of the capabilities of the remote bus. - */ - CapabilitiesFlags, - - /** - * The frequency with which short-polling clients should poll the remote bus. - */ - PollFrequency, - - /** - * Default value payload. Used mostly for higher-level APIs. - */ - Value, - - /** - * A unique identifier for identifying the session with which a message is associated. - */ - SessionID, - - /** - * Specifies any specific message text to be communicated as part of the command being sent. - */ - MessageText, - - /** - * Specifies what subject which should be replied-to in response to the message being sent. Usually handled - * automatically with conversations. - */ - ReplyTo, - - /** - * Specifies the intended recipient queue for the message. - */ - ToSubject, - - /** - * Specifies an error message. - */ - ErrorMessage, - - /** - * Additional details associated with an error message (for instance: stack trace information) - */ - AdditionalDetails, - - /** - * Specifies the subject to send error messages to. - */ - ErrorTo, - - /** - * The throwable object in case of an error - */ - Throwable, - - /** - * Specifies stack trace data in String form. - */ - StackTrace, - - Reason, - - /** - * If this attribute is present, the bus should give priority to processing it and not subject it to - * window matching. - */ - PriorityProcessing, - - - /** - * Used mainly for web sockets to negotiate which session the web socket is associated with. - */ - ConnectionSessionKey, - - WebSocketURL, - - WebSocketToken -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/protocols/Resources.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/protocols/Resources.java deleted file mode 100644 index a8250dbfba0..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/protocols/Resources.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.protocols; - -/** - * @author Mike Brock - */ -public enum Resources { - Session, SessionID, RetryAttempts -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/protocols/SerializationParts.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/protocols/SerializationParts.java deleted file mode 100644 index 9c0bde88714..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/protocols/SerializationParts.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.protocols; - -public class SerializationParts { - public static final String MARSHALLED_TYPES = "^MarshalledTypes"; - public static final String ENCODED_TYPE = "^EncodedType"; - public static final String OBJECT_ID = "^ObjectID"; - public static final String INSTANTIATE_ONLY = "^InstantiateOnly"; - public static final String NUMERIC_VALUE = "^NumVal"; - public static final String NULL_VALUE = "^NullVal"; - public static final String QUALIFIED_VALUE = "^Value"; - - // public static final String VALUE = "Value"; - - public static final String EMBEDDED_JSON = "^${$JSON$}$::"; - - public static final String ENUM_STRING_VALUE = "^EnumStringValue"; - - private SerializationParts() { - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/TypeHandler.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/TypeHandler.java deleted file mode 100644 index 543de5eefe7..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/TypeHandler.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.types; - -public interface TypeHandler { - public T getConverted(V in); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/TypeHandlerFactory.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/TypeHandlerFactory.java deleted file mode 100644 index 76570536f45..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/TypeHandlerFactory.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.types; - -import java.util.AbstractList; -import java.util.AbstractSet; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Queue; -import java.util.Set; -import java.util.Stack; - -import org.jboss.errai.common.client.types.handlers.collections.CollectionToBooleanArray; -import org.jboss.errai.common.client.types.handlers.collections.CollectionToDoubleArray; -import org.jboss.errai.common.client.types.handlers.collections.CollectionToIntArray; -import org.jboss.errai.common.client.types.handlers.collections.CollectionToList; -import org.jboss.errai.common.client.types.handlers.collections.CollectionToLongArray; -import org.jboss.errai.common.client.types.handlers.collections.CollectionToObjArray; -import org.jboss.errai.common.client.types.handlers.collections.CollectionToQueue; -import org.jboss.errai.common.client.types.handlers.collections.CollectionToSet; -import org.jboss.errai.common.client.types.handlers.collections.CollectionToStringArray; -import org.jboss.errai.common.client.types.handlers.numbers.NumberToByte; -import org.jboss.errai.common.client.types.handlers.numbers.NumberToDate; -import org.jboss.errai.common.client.types.handlers.numbers.NumberToFloat; -import org.jboss.errai.common.client.types.handlers.numbers.NumberToInt; -import org.jboss.errai.common.client.types.handlers.numbers.NumberToLong; -import org.jboss.errai.common.client.types.handlers.numbers.NumberToSQLDate; -import org.jboss.errai.common.client.types.handlers.numbers.NumberToShort; - -public class TypeHandlerFactory { - private static Map> handlers = - new HashMap>(); - - private static Map inheritanceMap = new HashMap(); - - static { - /** - * Declare all the default coercion handlers. - */ - final Map collectionHandlers = new HashMap(); - collectionHandlers.put(Object[].class, new CollectionToObjArray()); - collectionHandlers.put(String[].class, new CollectionToStringArray()); - collectionHandlers.put(Integer[].class, new CollectionToIntArray()); - collectionHandlers.put(Long[].class, new CollectionToLongArray()); - collectionHandlers.put(Boolean[].class, new CollectionToBooleanArray()); - collectionHandlers.put(Double[].class, new CollectionToDoubleArray()); - - collectionHandlers.put(Set.class, new CollectionToSet()); - collectionHandlers.put(List.class, new CollectionToList()); - collectionHandlers.put(Queue.class, new CollectionToQueue()); - - handlers.put(Collection.class, collectionHandlers); - - final Map numberHandlers = new HashMap(); - numberHandlers.put(Integer.class, new NumberToInt()); - numberHandlers.put(Long.class, new NumberToLong()); - numberHandlers.put(Short.class, new NumberToShort()); - numberHandlers.put(Float.class, new NumberToFloat()); - numberHandlers.put(Double.class, new NumberToFloat()); - numberHandlers.put(Byte.class, new NumberToByte()); - numberHandlers.put(java.util.Date.class, new NumberToDate()); - numberHandlers.put(java.sql.Date.class, new NumberToSQLDate()); - - handlers.put(Number.class, numberHandlers); - - /** - * Build an inheretence Map. - */ - inheritanceMap.put(Integer.class, Number.class); - inheritanceMap.put(Long.class, Number.class); - inheritanceMap.put(Short.class, Number.class); - inheritanceMap.put(Float.class, Number.class); - inheritanceMap.put(Double.class, Number.class); - - inheritanceMap.put(ArrayList.class, List.class); - inheritanceMap.put(LinkedList.class, List.class); - inheritanceMap.put(AbstractList.class, List.class); - inheritanceMap.put(Stack.class, List.class); - - inheritanceMap.put(HashSet.class, Set.class); - inheritanceMap.put(AbstractSet.class, Set.class); - - inheritanceMap.put(Set.class, Collection.class); - inheritanceMap.put(List.class, Collection.class); - - addHandler(String.class, Character.class, new TypeHandler() { - public Character getConverted(final String in) { - return in.charAt(0); - } - }); - } - - public static Map getHandler(final Class from) { - if (!handlers.containsKey(from) && inheritanceMap.containsKey(from)) { - return getHandler(inheritanceMap.get(from)); - } - else { - return handlers.get(from); - } - } - - public static T convert(final Object value, final Class to) { - if (value == null) return null; - return convert(value.getClass(), to, value); - } - - public static T convert(final Class from, final Class to, final Object value) { - if (value.getClass() == to) return (T) value; - final Map toHandlers = getHandler(from); - if (toHandlers == null) { - if (value instanceof String) { - /** - * We assume that this may be an enum type. It may not be, but we try to decode it - * as such. - */ - try { - T val = (T) Enum.valueOf((Class) to, (String) value); - - /** - * If we successfully decoded an enum, then we cache this handler for future - * use. - */ - addHandler(from, to, new TypeHandler() { - public T getConverted(final String in) { - return (T) Enum.valueOf((Class) to, in); - } - }); - - return val; - } - catch (Exception e) { - /** - * Definitely not an enum, so do nothing. - */ - return (T) value; - } - } - - return (T) value; - } - - if (toHandlers.containsKey(to)) { - return (T) toHandlers.get(to).getConverted(value); - } - else { - return (T) value; - } - } - - public static void addHandler(final Class from, final Class to, final TypeHandler handler) { - if (!handlers.containsKey(from)) { - handlers.put(from, new HashMap()); - } - handlers.get(from).put(to, handler); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToBooleanArray.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToBooleanArray.java deleted file mode 100644 index 240fc117d7c..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToBooleanArray.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.types.handlers.collections; - -import java.util.Collection; - -import org.jboss.errai.common.client.types.TypeHandler; - -public class CollectionToBooleanArray implements TypeHandler { - public Boolean[] getConverted(Collection in) { - if (in == null) return null; - Boolean[] newArray = new Boolean[in.size()]; - - int i = 0; - for (Object o : in) { - newArray[i++] = (Boolean) o; - } - - return newArray; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToByteArray.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToByteArray.java deleted file mode 100644 index 92420373f80..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToByteArray.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.types.handlers.collections; - -import java.util.Collection; - -import org.jboss.errai.common.client.types.TypeHandler; - -public class CollectionToByteArray implements TypeHandler { - public Byte[] getConverted(Collection in) { - if (in == null) return null; - Byte[] newArray = new Byte[in.size()]; - - int i = 0; - for (Object o : in) { - newArray[i++] = ((Number) o).byteValue(); - } - - return newArray; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToCharArray.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToCharArray.java deleted file mode 100644 index c5ff174bd6c..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToCharArray.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.types.handlers.collections; - -import java.util.Collection; - -import org.jboss.errai.common.client.types.TypeHandler; - -public class CollectionToCharArray implements TypeHandler { - public Character[] getConverted(Collection in) { - if (in == null) return null; - Character[] newArray = new Character[in.size()]; - - int i = 0; - for (Object o : in) { - newArray[i++] = String.valueOf(o).charAt(0); - } - - return newArray; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToDoubleArray.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToDoubleArray.java deleted file mode 100644 index 6627fd063c3..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToDoubleArray.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.types.handlers.collections; - -import java.util.Collection; - -import org.jboss.errai.common.client.types.TypeHandler; - -public class CollectionToDoubleArray implements TypeHandler { - public Double[] getConverted(Collection in) { - if (in == null) return null; - final Double[] newArray = new Double[in.size()]; - - int i = 0; - for (final Object o : in) { - newArray[i++] = ((Number) o).doubleValue(); - } - - return newArray; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToFloatArray.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToFloatArray.java deleted file mode 100644 index da9386b105b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToFloatArray.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.types.handlers.collections; - -import java.util.Collection; - -import org.jboss.errai.common.client.types.TypeHandler; - -public class CollectionToFloatArray implements TypeHandler { - public Float[] getConverted(Collection in) { - if (in == null) return null; - Float[] newArray = new Float[in.size()]; - - int i = 0; - for (Object o : in) { - newArray[i++] = ((Number) o).floatValue(); - } - - return newArray; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToIntArray.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToIntArray.java deleted file mode 100644 index bf42070697b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToIntArray.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.types.handlers.collections; - -import java.util.Collection; - -import org.jboss.errai.common.client.types.TypeHandler; - -public class CollectionToIntArray implements TypeHandler { - public Integer[] getConverted(Collection in) { - if (in == null) return null; - Integer[] newArray = new Integer[in.size()]; - - int i = 0; - for (Object o : in) { - newArray[i++] = ((Number) o).intValue(); - } - - return newArray; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToList.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToList.java deleted file mode 100644 index da647944b5f..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToList.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.types.handlers.collections; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.jboss.errai.common.client.types.TypeHandler; - -public class CollectionToList implements TypeHandler { - public List getConverted(Collection in) { - return new ArrayList(in); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToLongArray.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToLongArray.java deleted file mode 100644 index 2061a737e38..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToLongArray.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.types.handlers.collections; - -import java.util.Collection; - -import org.jboss.errai.common.client.types.TypeHandler; - -public class CollectionToLongArray implements TypeHandler { - public Long[] getConverted(Collection in) { - if (in == null) return null; - Long[] newArray = new Long[in.size()]; - - int i = 0; - for (Object o : in) { - newArray[i++] = ((Number) o).longValue(); - } - - return newArray; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToObjArray.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToObjArray.java deleted file mode 100644 index f3543d9c953..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToObjArray.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.types.handlers.collections; - -import java.util.Collection; - -import org.jboss.errai.common.client.types.TypeHandler; - -public class CollectionToObjArray implements TypeHandler { - public Object[] getConverted(Collection in) { - if (in == null) return null; - Object[] newArray = new Object[in.size()]; - - int i = 0; - for (Object o : in) { - newArray[i++] = o; - } - - return newArray; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToQueue.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToQueue.java deleted file mode 100644 index 3056e46c001..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToQueue.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.types.handlers.collections; - -import java.util.Collection; -import java.util.LinkedList; -import java.util.Queue; - -import org.jboss.errai.common.client.types.TypeHandler; - -public class CollectionToQueue implements TypeHandler { - public Queue getConverted(Collection in) { - return new LinkedList(in); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToSet.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToSet.java deleted file mode 100644 index 5de3352365f..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToSet.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.types.handlers.collections; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import org.jboss.errai.common.client.types.TypeHandler; - -public class CollectionToSet implements TypeHandler { - public Set getConverted(Collection in) { - return new HashSet(in); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToStringArray.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToStringArray.java deleted file mode 100644 index a38f874f400..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/collections/CollectionToStringArray.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.types.handlers.collections; - -import java.util.Collection; - -import org.jboss.errai.common.client.types.TypeHandler; - -public class CollectionToStringArray implements TypeHandler { - public String[] getConverted(Collection in) { - if (in == null) return null; - String[] newArray = new String[in.size()]; - - int i = 0; - for (Object o : in) { - newArray[i++] = String.valueOf(o); - } - - return newArray; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/numbers/NumberToByte.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/numbers/NumberToByte.java deleted file mode 100644 index 482fd6a0bd3..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/numbers/NumberToByte.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.types.handlers.numbers; - -import org.jboss.errai.common.client.types.TypeHandler; - -public class NumberToByte implements TypeHandler { - public Byte getConverted(Number in) { - return in.byteValue(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/numbers/NumberToDate.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/numbers/NumberToDate.java deleted file mode 100644 index 4df5c7ea6a1..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/numbers/NumberToDate.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.types.handlers.numbers; - -import java.util.Date; - -import org.jboss.errai.common.client.types.TypeHandler; - -public class NumberToDate implements TypeHandler { - public Date getConverted(Number in) { - return new Date(in.longValue()); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/numbers/NumberToDouble.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/numbers/NumberToDouble.java deleted file mode 100644 index 6d84a1f3da7..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/numbers/NumberToDouble.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.types.handlers.numbers; - -import org.jboss.errai.common.client.types.TypeHandler; - -public class NumberToDouble implements TypeHandler { - public Double getConverted(Number in) { - return in.doubleValue(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/numbers/NumberToFloat.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/numbers/NumberToFloat.java deleted file mode 100644 index edf12420faf..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/numbers/NumberToFloat.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.types.handlers.numbers; - -import org.jboss.errai.common.client.types.TypeHandler; - -public class NumberToFloat implements TypeHandler { - public Float getConverted(Number in) { - return in.floatValue(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/numbers/NumberToInt.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/numbers/NumberToInt.java deleted file mode 100644 index cc582ea72e6..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/numbers/NumberToInt.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.types.handlers.numbers; - -import org.jboss.errai.common.client.types.TypeHandler; - -public class NumberToInt implements TypeHandler { - public Integer getConverted(Number in) { - return in.intValue(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/numbers/NumberToLong.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/numbers/NumberToLong.java deleted file mode 100644 index 906be16307d..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/numbers/NumberToLong.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.types.handlers.numbers; - -import org.jboss.errai.common.client.types.TypeHandler; - -public class NumberToLong implements TypeHandler { - public Long getConverted(Number in) { - return in.longValue(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/numbers/NumberToSQLDate.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/numbers/NumberToSQLDate.java deleted file mode 100644 index 2130f56609c..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/numbers/NumberToSQLDate.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.types.handlers.numbers; - -import java.sql.Date; - -import org.jboss.errai.common.client.types.TypeHandler; - -public class NumberToSQLDate implements TypeHandler { - public Date getConverted(Number in) { - return new Date(in.longValue()); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/numbers/NumberToShort.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/numbers/NumberToShort.java deleted file mode 100644 index fba427ab1f3..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/types/handlers/numbers/NumberToShort.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.types.handlers.numbers; - -import org.jboss.errai.common.client.types.TypeHandler; - -public class NumberToShort implements TypeHandler { - public Short getConverted(Number in) { - return in.shortValue(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/ui/ElementWrapperWidget.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/ui/ElementWrapperWidget.java deleted file mode 100644 index 2dc0d02700e..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/ui/ElementWrapperWidget.java +++ /dev/null @@ -1,317 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.ui; - -import java.util.HashMap; -import java.util.Map; - -import com.google.gwt.dom.client.Element; -import com.google.gwt.dom.client.InputElement; -import com.google.gwt.dom.client.TextAreaElement; -import com.google.gwt.event.logical.shared.ValueChangeEvent; -import com.google.gwt.event.logical.shared.ValueChangeHandler; -import com.google.gwt.event.shared.HandlerRegistration; -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.Event; -import com.google.gwt.user.client.EventListener; -import com.google.gwt.user.client.ui.HasHTML; -import com.google.gwt.user.client.ui.HasValue; -import com.google.gwt.user.client.ui.RootPanel; -import com.google.gwt.user.client.ui.Widget; -import org.jboss.errai.common.client.ui.NativeHasValueAccessors.Accessor; - -/** - * A widget that wraps an {@link Element} to support the registration of event listeners and data - * binding. - * - * @author Lincoln Baxter, III - * @author Christian Sadilek - */ -public abstract class ElementWrapperWidget extends Widget { - private static Map> widgetMap = new HashMap<>(); - - public static ElementWrapperWidget getWidget(final Element element) { - return getWidget(element, null); - } - - public static ElementWrapperWidget getWidget(final elemental2.dom.HTMLElement element) { - return getWidget(element, null); - } - - public static ElementWrapperWidget getWidget(final Element element, final Class valueType) { - return getWidget((Object) element, valueType); - } - - public static ElementWrapperWidget getWidget(final Object obj, final Class valueType) { - final Element element = asElement(obj); - ElementWrapperWidget widget = widgetMap.get(element); - if (widget == null) { - widget = createElementWrapperWidget(element, valueType); - // Always call onAttach so that events propogatge even if this has no widget parent. - widget.onAttach(); - RootPanel.detachOnWindowClose(widget); - widgetMap.put(element, widget); - } - else if (valueType != null && !valueType.equals(widget.getValueType())) { - throw new RuntimeException( - "There already exists a widget for the given element with a different value type. Expected " - + widget.getValueType().getName() + " but was passed in " + valueType.getName()); - } - - return widget; - } - - private static native Element asElement(Object obj) /*-{ - return obj; - }-*/; - - @SuppressWarnings({ "rawtypes", "unchecked" }) - private static ElementWrapperWidget createElementWrapperWidget(final Element element, final Class valueType) { - if (valueType != null) { - final Accessor accessor; - if (NativeHasValueAccessors.hasValueAccessor(element)) { - accessor = NativeHasValueAccessors.getAccessor(element); - } - else { - accessor = new DefaultAccessor((org.jboss.errai.common.client.ui.HasValue) element); - } - - return new JsTypeHasValueElementWrapperWidget<>(element, accessor, valueType); - } - else if (InputElement.is(element) || TextAreaElement.is(element)) { - return new InputElementWrapperWidget<>(element); - } - else { - return new DefaultElementWrapperWidget<>(element); - } - } - - public static Class getValueClassForInputType(final String inputType) { - if ("checkbox".equalsIgnoreCase(inputType) || "radio".equalsIgnoreCase(inputType)) { - return Boolean.class; - } - else { - return String.class; - } - } - - private static boolean different(final Object oldValue, final Object newValue) { - return (oldValue == null ^ newValue == null) || (oldValue != null && !oldValue.equals(newValue)); - } - - public static ElementWrapperWidget removeWidget(final Element element) { - return widgetMap.remove(element); - } - - public static ElementWrapperWidget removeWidget(final ElementWrapperWidget widget) { - return widgetMap.remove(widget.getElement()); - } - - private static abstract class HasValueElementWrapperWidget extends ElementWrapperWidget implements HasValue { - - private final ValueChangeManager> valueChangeManager = new ValueChangeManager<>(this); - - private HasValueElementWrapperWidget(final Element element) { - super(element); - } - - @Override - public void setValue(final T value, final boolean fireEvents) { - final T oldValue = getValue(); - setValue(value); - if (fireEvents && different(oldValue, value)) { - ValueChangeEvent.fire(this, value); - } - } - - @Override - public HandlerRegistration addValueChangeHandler(final ValueChangeHandler handler) { - return valueChangeManager.addValueChangeHandler(handler); - } - - } - - private static class DefaultAccessor implements Accessor { - - private final org.jboss.errai.common.client.ui.HasValue instance; - - private DefaultAccessor(final org.jboss.errai.common.client.ui.HasValue instance) { - this.instance = instance; - } - - @Override - public T get() { - try { - return instance.getValue(); - } catch (final Throwable t) { - throw new RuntimeException("Unable to invoke getValue() on JsType: " + t.getMessage(), t); - } - } - - @Override - public void set(final T value) { - try { - instance.setValue(value); - } catch (final Throwable t) { - throw new RuntimeException("Unable to invoke setValue(T value) on JsType: " + t.getMessage(), t); - } - } - - } - - private static class JsTypeHasValueElementWrapperWidget extends HasValueElementWrapperWidget { - - private final Class valueType; - private final Accessor accessor; - - private JsTypeHasValueElementWrapperWidget(final Element element, final Accessor accessor, final Class valueType) { - super(element); - this.accessor = accessor; - this.valueType = valueType; - } - - @Override - public T getValue() { - return accessor.get(); - } - - @Override - public void setValue(final T value) { - accessor.set(value); - } - - @Override - public Class getValueType() { - return valueType; - } - - } - - private static class InputElementWrapperWidget extends HasValueElementWrapperWidget { - - private InputElementWrapperWidget(final Element element) { - super(element); - } - - @Override - public void setValue(final T value) { - final String inputType = getElement().getPropertyString("type"); - final Class valueType = getValueClassForInputType(inputType); - - if (Boolean.class.equals(valueType)) { - getElement().setPropertyBoolean("checked", (Boolean) value); - } else if (String.class.equals(valueType)) { - getElement().setPropertyObject("value", value != null ? value : ""); - } else { - throw new IllegalArgumentException("Cannot set value " + value + " to element input[type=\"" + inputType + "\"]."); - } - } - - @SuppressWarnings("unchecked") - @Override - public T getValue() { - final String inputType = getElement().getPropertyString("type"); - final Class valueType = getValueClassForInputType(inputType); - if (Boolean.class.equals(valueType)) { - return (T) (Boolean) getElement().getPropertyBoolean("checked"); - } - else if (String.class.equals(valueType)) { - final Object rawValue = getElement().getPropertyObject("value"); - return (T) (rawValue != null ? rawValue : ""); - } - else { - throw new RuntimeException("Unrecognized input element type [" + inputType + "]"); - } - } - - @Override - public Class getValueType() { - return getValueClassForInputType(getElement().getPropertyString("type")); - } - - } - - private static class DefaultElementWrapperWidget extends ElementWrapperWidget implements HasHTML { - - private DefaultElementWrapperWidget(final Element element) { - super(element); - } - - @Override - public String getText() { - return getElement().getInnerText(); - } - - @Override - public void setText(final String text) { - getElement().setInnerText(text); - } - - @Override - public String getHTML() { - return getElement().getInnerHTML(); - } - - @Override - public void setHTML(final String html) { - getElement().setInnerHTML(html); - } - - @Override - public Class getValueType() { - return String.class; - } - - } - - private EventListener listener = new EventListener() { - @Override - public void onBrowserEvent(final Event event) { - ElementWrapperWidget.super.onBrowserEvent(event); - } - }; - - private ElementWrapperWidget(final Element wrapped) { - if (wrapped == null) { - throw new IllegalArgumentException( - "Element to be wrapped must not be null - Did you forget to initialize or @Inject a UI field?"); - } - this.setElement(wrapped); - DOM.setEventListener(this.getElement(), this); - } - - public void setEventListener(final int eventsToSink, final EventListener listener) { - if (listener == null) { - throw new IllegalArgumentException("EventListener cannot be null."); - } - - sinkEvents(eventsToSink); - this.listener = listener; - } - - @Override - public void onBrowserEvent(final Event event) { - listener.onBrowserEvent(event); - } - - public abstract Class getValueType(); - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/ui/HasValue.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/ui/HasValue.java deleted file mode 100644 index 658d63863c5..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/ui/HasValue.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.ui; - -import jsinterop.annotations.JsOverlay; -import jsinterop.annotations.JsType; - -/** - * Like {@link com.google.gwt.user.client.ui.HasValue} but for native {@link JsType JsTypes}. - * - * When a native type implementing {@link HasValue} is bound with Errai Data-Binding, the {@link #getValue()} and - * {@link #setValue(Object)} will be used. (This is only supported in declarative data-binding because of limitations - * with native JS types.) - * - * It is possible to create a native {@link JsType} where {@link #getValue()} and {@link #setValue(Object)} are - * implemented as {@link JsOverlay} methods, providing an easy way to define value accessors for native types with Errai - * Data-Binding. - * - * @author Max Barkley - */ -@JsType(isNative = true) -public interface HasValue { - - T getValue(); - - void setValue(T value); - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/ui/NativeHasValueAccessors.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/ui/NativeHasValueAccessors.java deleted file mode 100644 index 635ddf6eb81..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/ui/NativeHasValueAccessors.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.ui; - -import java.util.IdentityHashMap; -import java.util.Map; - -/** - * - * @author Max Barkley - */ -public class NativeHasValueAccessors { - - public static interface Accessor { - T get(); - void set(T value); - } - - private static final Map> instanceAccessors = new IdentityHashMap<>(); - - public static void registerAccessor(final Object instance, final Accessor accessor) { - instanceAccessors.put(instance, accessor); - } - - public static Accessor getAccessor(final Object instance) { - final Accessor accessor = instanceAccessors.get(instance); - if (accessor == null) { - throw new RuntimeException("No accessor found for " + instance); - } - else { - return accessor; - } - } - - public static boolean hasValueAccessor(final Object instance) { - return instanceAccessors.containsKey(instance); - } - - private NativeHasValueAccessors() {} - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/ui/ValueChangeManager.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/ui/ValueChangeManager.java deleted file mode 100644 index 2d20a37f81d..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/ui/ValueChangeManager.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.ui; - -import com.google.gwt.event.dom.client.ChangeEvent; -import com.google.gwt.event.dom.client.ChangeHandler; -import com.google.gwt.event.logical.shared.HasValueChangeHandlers; -import com.google.gwt.event.logical.shared.ValueChangeEvent; -import com.google.gwt.event.logical.shared.ValueChangeHandler; -import com.google.gwt.event.shared.GwtEvent; -import com.google.gwt.event.shared.HandlerRegistration; -import com.google.gwt.user.client.ui.HasValue; -import com.google.gwt.user.client.ui.Widget; - -/** - * Utility class for managing widgets implementing {@link HasValue}. - * - * @author Max Barkley - */ -public class ValueChangeManager> implements HasValueChangeHandlers { - - private boolean valueChangeHandlerInitialized; - private final W widget; - - public ValueChangeManager(final W widget) { - this.widget = widget; - } - - @Override - public void fireEvent(final GwtEvent event) { - widget.fireEvent(event); - } - - @Override - public HandlerRegistration addValueChangeHandler(final ValueChangeHandler handler) { - if (!valueChangeHandlerInitialized) { - valueChangeHandlerInitialized = true; - widget.addDomHandler(new ChangeHandler() { - @Override - public void onChange(ChangeEvent event) { - ValueChangeEvent.fire(widget, widget.getValue()); - } - }, ChangeEvent.getType()); - } - return widget.addHandler(handler, ValueChangeEvent.getType()); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/util/AnnotationPropertyAccessor.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/util/AnnotationPropertyAccessor.java deleted file mode 100644 index d6e70ee2f65..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/util/AnnotationPropertyAccessor.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.jboss.errai.common.client.util; - -import java.lang.annotation.Annotation; -import java.util.Map; -import java.util.function.Function; - -public class AnnotationPropertyAccessor { - final Map> accessorsByPropertyName; - - public AnnotationPropertyAccessor(final Map> accessorsByPropertyName) { - this.accessorsByPropertyName = accessorsByPropertyName; - } -} \ No newline at end of file diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/util/AnnotationPropertyAccessorBuilder.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/util/AnnotationPropertyAccessorBuilder.java deleted file mode 100644 index 9f08af27f29..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/util/AnnotationPropertyAccessorBuilder.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.jboss.errai.common.client.util; - -import java.lang.annotation.Annotation; -import java.util.Collections; -import java.util.Map; -import java.util.SortedMap; -import java.util.TreeMap; -import java.util.function.Function; - -public class AnnotationPropertyAccessorBuilder { - private final SortedMap> accessorsByPropertyName = new TreeMap<>(); - - private AnnotationPropertyAccessorBuilder() {} - - public static AnnotationPropertyAccessorBuilder create() { - return new AnnotationPropertyAccessorBuilder(); - } - - public AnnotationPropertyAccessorBuilder with(final String propertyName, final Function accessor) { - accessorsByPropertyName.put(propertyName, accessor); - - return this; - } - - public AnnotationPropertyAccessor build() { - return new AnnotationPropertyAccessor(createOrderedPropertyMap()); - } - - private Map> createOrderedPropertyMap() { - return (accessorsByPropertyName.isEmpty() ? Collections.emptyMap() : Collections.unmodifiableMap(accessorsByPropertyName)); - } -} \ No newline at end of file diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/util/AsyncBeanFactory.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/util/AsyncBeanFactory.java deleted file mode 100644 index 02f16d20d07..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/util/AsyncBeanFactory.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.util; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.core.client.RunAsyncCallback; - -/** - * Dispatches a created bean via a callback. - * - * @author eric.wittmann@redhat.com - */ -public class AsyncBeanFactory { - - /** - * Deliver/dispatch the new bean instance asynchronously. - * @param bean - * @param callback - */ - public static final void createBean(final Object bean, @SuppressWarnings("rawtypes") final CreationalCallback callback) { - GWT.runAsync(new RunAsyncCallback() { - @SuppressWarnings("unchecked") - public void onSuccess() { - callback.callback(bean); - } - public void onFailure(Throwable caught) { - // can't really fail - } - }); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/util/Base64Util.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/util/Base64Util.java deleted file mode 100644 index 8344bbf6340..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/util/Base64Util.java +++ /dev/null @@ -1,235 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.util; - - -/** - * Base64 String to-and-from byte array utility. - *

- * This code is a modified version of Base64Encoder from the gwt-crypto project, used under the terms of the ASL 2.0 license. - * - * @author gwt-crypto project (original encode/decode logic) - * @author Jonathan Fuerth (modified for Errai by removing - * usage of java.io) - */ -public class Base64Util { - - private static final byte[] encodingTable = {(byte) 'A', (byte) 'B', (byte) 'C', - (byte) 'D', (byte) 'E', (byte) 'F', (byte) 'G', (byte) 'H', (byte) 'I', - (byte) 'J', (byte) 'K', (byte) 'L', (byte) 'M', (byte) 'N', (byte) 'O', - (byte) 'P', (byte) 'Q', (byte) 'R', (byte) 'S', (byte) 'T', (byte) 'U', - (byte) 'V', (byte) 'W', (byte) 'X', (byte) 'Y', (byte) 'Z', (byte) 'a', - (byte) 'b', (byte) 'c', (byte) 'd', (byte) 'e', (byte) 'f', (byte) 'g', - (byte) 'h', (byte) 'i', (byte) 'j', (byte) 'k', (byte) 'l', (byte) 'm', - (byte) 'n', (byte) 'o', (byte) 'p', (byte) 'q', (byte) 'r', (byte) 's', - (byte) 't', (byte) 'u', (byte) 'v', (byte) 'w', (byte) 'x', (byte) 'y', - (byte) 'z', (byte) '0', (byte) '1', (byte) '2', (byte) '3', (byte) '4', - (byte) '5', (byte) '6', (byte) '7', (byte) '8', (byte) '9', (byte) '+', - (byte) '/'}; - - - protected static final byte padding = (byte) '='; - - protected static final byte[] decodingTable = new byte[128]; - - static { - for (int i = 0; i < encodingTable.length; i++) { - decodingTable[encodingTable[i]] = (byte) i; - } - } - - /** - * Same as {@link #encode(byte[], int, int)} but accepts an array of boxed - * Byte values. - * - * @param data - * The sequence of bytes to encode. Every element must be non-null. - * @param off - * The offset into the data array to start encoding from - * @param length - * The number of bytes to encode, starting from {@code off} - * - * @return The base64 encoded data. - */ - public static String encode(final Byte[] data, final int off, final int length) { - final byte[] primitiveData = new byte[data.length]; - for (int i = 0; i < length; i++) { - primitiveData[i] = data[off + i]; - } - return encode(primitiveData, 0, primitiveData.length); - } - - /** - * Encodes the input data, producing a base 64 string. - * - * @param data - * the data to encode. It is assumed that none of the elements are - * null. - * @param off - * The offset into the data array to start encoding from - * @param length - * The number of bytes to encode, starting from {@code off} - * - * @return the base64 representation of the given binary data. - */ - public static String encode(final byte[] data, final int off, final int length) { - final StringBuilder sb = new StringBuilder(); - final int modulus = length % 3; - final int dataLength = (length - modulus); - int a1, a2, a3; - - for (int i = off; i < off + dataLength; i += 3) { - a1 = data[i] & 0xff; - a2 = data[i + 1] & 0xff; - a3 = data[i + 2] & 0xff; - - sb.append((char) encodingTable[(a1 >>> 2) & 0x3f]); - sb.append((char) encodingTable[((a1 << 4) | (a2 >>> 4)) & 0x3f]); - sb.append((char) encodingTable[((a2 << 2) | (a3 >>> 6)) & 0x3f]); - sb.append((char) encodingTable[a3 & 0x3f]); - } - - /* - * process the tail end. - */ - final int d1; - final int d2; - - switch (modulus) { - case 0: /* nothing left to do */ - break; - case 1: - d1 = data[off + dataLength] & 0xff; - - sb.append((char) encodingTable[(d1 >>> 2) & 0x3f]); - sb.append((char) encodingTable[(d1 << 4) & 0x3f]); - sb.append((char) padding); - sb.append((char) padding); - break; - case 2: - d1 = data[off + dataLength] & 0xff; - d2 = data[off + dataLength + 1] & 0xff; - - sb.append((char) encodingTable[(d1 >>> 2) & 0x3f]); - sb.append((char) encodingTable[((d1 << 4) | (d2 >>> 4)) & 0x3f]); - sb.append((char) encodingTable[(d2 << 2) & 0x3f]); - sb.append((char) padding); - break; - } - - return sb.toString(); - } - - private static boolean ignore(final char c) { - return (c == '\n' || c == '\r' || c == '\t' || c == ' '); - } - - public static Byte[] decodeAsBoxed(final String data) { - final byte[] primitiveArray = decode(data); - final Byte[] boxedData = new Byte[primitiveArray.length]; - for (int i = 0; i < primitiveArray.length; i++) { - boxedData[i] = primitiveArray[i]; - } - return boxedData; - } - - /** - * Decodes the Base64-encoded String to the equivalent binary data array. - * Whitespace characters in the input stream are ignored. - * - * @return the binary data decoded from the input string - */ - public static byte[] decode(final String data) { - byte b2, b3; - - if (data.isEmpty()) { - return new byte[0]; - } - - int end = data.length(); - - while (end > 0) { - if (!ignore(data.charAt(end - 1))) { - break; - } - - end--; - } - - final byte[] lastBlock = new byte[3]; - final int bytesInLastBlock = decodeLastBlock( - lastBlock, 0, - data.charAt(end - 4), data.charAt(end - 3), - data.charAt(end - 2), data.charAt(end - 1)); - - final byte[] out = new byte[data.length() / 4 * 3 - (3 - bytesInLastBlock)]; - int outpos = 0; - - int i = 0; - final int finish = end - 4; - - while (i < finish) { - out[outpos++] = (byte) ((decodingTable[data.charAt(i = nextI(data, i, finish))] << 2) | ((b2 = decodingTable[data.charAt(i = nextI(data, ++i, finish))]) >> 4)); - out[outpos++] = (byte) ((b2 << 4) | ((b3 = decodingTable[data.charAt(i = nextI(data, ++i, finish))]) >> 2)); - out[outpos++] = (byte) ((b3 << 6) | decodingTable[data.charAt(i = nextI(data, ++i, finish))]); - - i = nextI(data, i, finish); - i++; - } - - for (int j = 0; j < bytesInLastBlock; j++) { - out[outpos++] = lastBlock[j]; - } - - return out; - } - - private static int decodeLastBlock( - final byte[] out, int outpos, final char c1, final char c2, final char c3, final char c4) { - - if (c3 == padding) { - out[outpos] = (byte) ((decodingTable[c1] << 2) | (decodingTable[c2] >> 4)); - return 1; - } - else if (c4 == padding) { - out[outpos++] = (byte) ((decodingTable[c1] << 2) | (decodingTable[c2] >> 4)); - out[outpos] = (byte) ((decodingTable[c2] << 4) | (decodingTable[c3] >> 2)); - - return 2; - } - else { - out[outpos++] = (byte) ((decodingTable[c1] << 2) | (decodingTable[c2] >> 4)); - out[outpos++] = (byte) ((decodingTable[c2] << 4) | (decodingTable[c3] >> 2)); - out[outpos] = (byte) ((decodingTable[c3] << 6) | decodingTable[c4]); - - return 3; - } - } - - private static int nextI(final String data, int i, final int finish) { - while ((i < finish) && ignore(data.charAt(i))) { - i++; - } - return i; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/util/CreationalCallback.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/util/CreationalCallback.java deleted file mode 100644 index 6b626018764..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/util/CreationalCallback.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.util; - -/** - * @author Mike Brock - */ -public interface CreationalCallback { - public void callback(T beanInstance); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/util/EventTestingUtil.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/util/EventTestingUtil.java deleted file mode 100644 index d96db437e3b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/util/EventTestingUtil.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.util; - -import com.google.gwt.dom.client.Document; -import com.google.gwt.dom.client.Element; -import com.google.gwt.dom.client.NativeEvent; -import com.google.gwt.event.logical.shared.ValueChangeEvent; -import com.google.gwt.user.client.ui.HasValue; -import org.jboss.errai.common.client.ui.ElementWrapperWidget; - -/** - * Contains utility methods for intercepting calls to add and remove web browser event listeners necessary for tests - * with certain versions of HTMLUnit. - * - * @author Max Barkley - */ -public abstract class EventTestingUtil { - - private EventTestingUtil() {} - - /** - * This is a really disgusting workaround for the inability to - * dispatch native browser events in the version of HtmlUnit currently - * bundled in gwt-dev. - * - * What does this do? - * This replaces "addEventListener" and "removeEventListener" - * in the HTMLElement prototype with functions that intercept - * and store registered listeners. - * - * Why does it do it? - * So that subsequent calls to "invokeEventListeners" can - * manually call any functions added with "addEventListener". - * - * In short because we cannot dispatch browser events, to test - * binding of native elements we must store and then manually invoke - * all event listeners. - */ - public static native void setupAddEventListenerInterceptor() /*-{ - console.log("Setting up event listener interceptors."); - function ListenerMap() { - var map = new Map(); - - this.add = function(element, type, listener) { - var curList = this.get(element, type); - console.debug("Adding listener for " + type + " event in " + element + ". Total of " + (curList.length + 1) + " listeners."); - curList.push(listener); - }; - - this.remove = function(element, type, listener) { - var listeners = this.get(element, type); - var index = listeners.indexOf(listener); - if (index > -1) { - listeners.splice(index, 1); - } - }; - - this.get = function(element, type) { - if (map.get(element) === undefined) { - map.set(element, new Map()); - } - if (map.get(element).get(type) === undefined) { - map.get(element).set(type, []); - } - return map.get(element).get(type); - }; - }; - if ($wnd.HTMLElement.prototype._addEventListener === undefined) { - listeners = new ListenerMap(); - $wnd.HTMLElement.prototype._addEventListener = $wnd.HTMLElement.prototype.addEventListener; - $wnd.HTMLElement.prototype._removeEventListener = $wnd.HTMLElement.prototype.removeEventListener; - console.log("Replacing addEventListener."); - $wnd.HTMLElement.prototype.addEventListener = function(type, listener, capture) { - console.debug("Intercepted addEventListener(" + this + ", " + type + ", " + capture + ")"); - listeners.add(this, type, listener); - this._addEventListener(type, listener, capture); - }; - console.log("Replacing removeEventListener."); - $wnd.HTMLElement.prototype.removeEventListener = function(type, listener, capture) { - console.debug("Intercepted removeEventListener for " + this + " with type " + type); - listeners.remove(this, type, listener); - this._removeEventListener(type, listener, capture); - }; - } - }-*/; - - @SuppressWarnings({ "unchecked", "rawtypes" }) - public static void invokeEventListeners(final Element element, final String eventType) { - invokeEventListeners((Object) element, eventType); - if ("change".equals(eventType)) { - final ElementWrapperWidget elem = ElementWrapperWidget.getWidget(element); - if (elem instanceof HasValue) { - ValueChangeEvent.fire(((HasValue) elem), ((HasValue) elem).getValue()); - } - } - } - - public static void invokeEventListeners(final Object element, final String eventType) { - final NativeEvent event = Document.get().createHtmlEvent(eventType, true, true); - invokeEventListeners(element, eventType, event); - } - - public static native void invokeEventListeners(Object element, String type, Object evt) /*-{ - var foundListeners = listeners.get(element, type); - console.debug("Found " + foundListeners.length + " for " + type + " event on element " + element); - foundListeners.forEach(function(l) { l(evt); }); - }-*/; - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/util/Properties.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/util/Properties.java deleted file mode 100644 index 653877e3206..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/util/Properties.java +++ /dev/null @@ -1,272 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.util; - -import java.util.HashMap; -import java.util.Map; - -/** - * A utility for parsing .properties files in GWT code. - * - * @author Max Barkley - */ -public class Properties { - - /** - * @param data - * The contents of a .properties file. - * @return A map of key-value pairs parsed from the .properties file contents. - */ - public static Map load(final String data) { - final ParseState parseState = new ParseState(data); - while (parseState.next()); - - return parseState.properties; - } - - private static class ParseState { - private static enum State { - LINE_START { - @Override - ParseState accept(final char input, final ParseState state) { - if (input == '!' || input == '#') { - state.state = COMMENT; - state.index += 1; - } - else { - state.state = PRE_KEY_WHITESPACE; - } - - return state; - } - }, - COMMENT { - @Override - ParseState accept(final char input, final ParseState state) { - if (input == '\n') { - state.state = LINE_START; - } - state.index += 1; - - return state; - } - }, - PRE_KEY_WHITESPACE { - @Override - ParseState accept(final char input, final ParseState state) { - if (Character.isWhitespace(input)) { - state.index += 1; - } - else { - state.state = KEY; - } - return state; - } - }, - KEY { - @Override - ParseState accept(final char input, final ParseState state) { - if (Character.isWhitespace(input)) { - state.state = POST_KEY_WHITESPACE; - } - else if (isSeparator(input)) { - state.state = PRE_VALUE_WHITESPACE; - state.index += 1; - } - else { - state.key.append(input); - state.index += 1; - } - return state; - } - }, - POST_KEY_WHITESPACE { - @Override - ParseState accept(final char input, final ParseState state) { - if (Character.isWhitespace(input)) { - state.index += 1; - } - else if (isSeparator(input)) { - state.index += 1; - state.state = PRE_VALUE_WHITESPACE; - } - else { - state.state = VALUE_UNESCAPED; - } - - return state; - } - }, - PRE_VALUE_WHITESPACE { - @Override - ParseState accept(final char input, final ParseState state) { - if (Character.isWhitespace(input)) { - state.index += 1; - } - else { - state.state = VALUE_UNESCAPED; - } - - return state; - } - }, - VALUE_UNESCAPED { - @Override - ParseState accept(final char input, final ParseState state) { - if (input == '\\') { - state.index += 1; - state.state = VALUE_ESCAPED; - } - else if (input == '\n' || input == '\r') { - state.state = LINE_ENDING; - } - else { - state.index += 1; - state.value.append(input); - } - - return state; - } - }, - VALUE_ESCAPED { - @Override - ParseState accept(final char input, final ParseState state) { - if (Character.isWhitespace(input)) { - state.state = VALUE_IGNORED; - } - else { - state.index += 1; - state.state = VALUE_UNESCAPED; - switch (input) { - case 'r': - state.value.append('\r'); - break; - case 't': - state.value.append('\t'); - break; - case 'n': - state.value.append('\n'); - break; - case '=': - state.value.append('='); - break; - case ':': - state.value.append(':'); - break; - case '\\': - state.value.append('\\'); - break; - case 'u': - final String hexDigits = state.data.substring(state.index, state.index+4); - state.index += 4; - final int escapedChar = Integer.parseInt(hexDigits, 16); - state.value.append((char) escapedChar); - break; - default: - state.state = VALUE_IGNORED; - return state; - } - - } - - return state; - } - }, - VALUE_IGNORED { - @Override - ParseState accept(final char input, final ParseState state) { - if (input == '\n') { - state.index += 1; - state.state = PRE_VALUE_WHITESPACE; - } - else { - state.index += 1; - } - - return state; - } - }, - LINE_END { - @Override - ParseState accept(final char input, final ParseState state) { - state.state = LINE_START; - state.index += 1; - - return state; - } - }, - LINE_ENDING { - @Override - ParseState accept(final char input, final ParseState state) { - state.state = LINE_END; - if (input == '\r') { - if (state.data.charAt(state.index+1) == '\n') { - state.index += 1; - } - } - - return state; - } - }; - - abstract ParseState accept(char input, ParseState state); - static boolean isSeparator(final char input) { - return input == '=' || input == ':'; - } - } - - final StringBuilder key = new StringBuilder(), value = new StringBuilder(); - State state = State.LINE_START; - final String data; - int index = 0; - final Map properties = new HashMap<>(); - - ParseState(final String date) { - this.data = date; - } - - boolean next() { - if (index > data.length()) { - return false; - } - - if (State.LINE_END.equals(state) || index == data.length()) { - if (key.length() > 0 || value.length() > 0) { - properties.put(key.toString(), value.toString()); - key.delete(0, key.length()); - value.delete(0, value.length()); - } - if (index == data.length()) { - index += 1; - return false; - } - } - - final char c = data.charAt(index); - state.accept(c, this); - - return true; - } - } - - private Properties() {} - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/util/SharedAnnotationSerializer.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/util/SharedAnnotationSerializer.java deleted file mode 100644 index 5c7e79a31e1..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/util/SharedAnnotationSerializer.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.util; - -import java.lang.annotation.Annotation; -import java.util.Arrays; -import java.util.Map; -import java.util.function.Function; - -/** - * - * @author Max Barkley - */ -public class SharedAnnotationSerializer { - - public static String serialize(final Annotation qualifier, final AnnotationPropertyAccessor entry) { - if (entry != null) { - final StringBuilder builder = new StringBuilder(qualifier.annotationType().getName()); - if (!entry.accessorsByPropertyName.isEmpty()) { - builder.append('('); - for (final Map.Entry> e : entry.accessorsByPropertyName.entrySet()) { - builder.append(e.getKey()) - .append('=') - .append(e.getValue().apply(qualifier)) - .append(','); - } - builder.replace(builder.length()-1, builder.length(), ")"); - } - - return builder.toString(); - } - else { - return qualifier.annotationType().getName(); - } - } - - public static String stringify(final Object value) { - return String.valueOf(value); - } - - public static String stringify(final Class[] value) { - return Arrays.toString(value); - } - - public static String stringify(final byte[] value) { - return Arrays.toString(value); - } - - public static String stringify(final int[] value) { - return Arrays.toString(value); - } - - public static String stringify(final short[] value) { - return Arrays.toString(value); - } - - public static String stringify(final char[] value) { - return Arrays.toString(value); - } - - public static String stringify(final float[] value) { - return Arrays.toString(value); - } - - public static String stringify(final double[] value) { - return Arrays.toString(value); - } - - public static String stringify(final String[] value) { - return Arrays.toString(value); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/util/TimeUnit.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/util/TimeUnit.java deleted file mode 100644 index 85e9241859e..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/client/util/TimeUnit.java +++ /dev/null @@ -1,465 +0,0 @@ -/* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain - */ - -package org.jboss.errai.common.client.util; - -/** - * A TimeUnit represents time durations at a given unit of - * granularity and provides utility methods to convert across units, - * and to perform timing and delay operations in these units. A - * TimeUnit does not maintain time information, but only - * helps organize and use time representations that may be maintained - * separately across various contexts. A nanosecond is defined as one - * thousandth of a microsecond, a microsecond as one thousandth of a - * millisecond, a millisecond as one thousandth of a second, a minute - * as sixty seconds, an hour as sixty minutes, and a day as twenty four - * hours. - *

- *

A TimeUnit is mainly used to inform time-based methods - * how a given timing parameter should be interpreted. For example, - * the following code will timeout in 50 milliseconds if the {@link - * java.util.concurrent.locks.Lock lock} is not available: - *

- *

  Lock lock = ...;
- *  if ( lock.tryLock(50L, TimeUnit.MILLISECONDS) ) ...
- * 
- * while this code will timeout in 50 seconds: - *
- *  Lock lock = ...;
- *  if ( lock.tryLock(50L, TimeUnit.SECONDS) ) ...
- * 
- *

- * Note however, that there is no guarantee that a particular timeout - * implementation will be able to notice the passage of time at the - * same granularity as the given TimeUnit. - *

- * This implementation has been modified to work within the GWT client - * emulation layer. - * - * @author Doug Lea - * @since 1.5 - */ -public enum TimeUnit { - NANOSECONDS { - public long toNanos(final long d) { - return d; - } - - public long toMicros(final long d) { - return d / (C1); - } - - public long toMillis(final long d) { - return d / (C2); - } - - public long toSeconds(final long d) { - return d / (C3); - } - - public long toMinutes(final long d) { - return d / (C4); - } - - public long toHours(final long d) { - return d / (C5); - } - - public long toDays(final long d) { - return d / (C6); - } - - public long convert(final long d, final TimeUnit u) { - return u.toNanos(d); - } - - int excessNanos(final long d, final long m) { - return (int) (d - (m * C2)); - } - }, - MICROSECONDS { - public long toNanos(final long d) { - return x(d, C1, Long.MAX_VALUE / (C1)); - } - - public long toMicros(final long d) { - return d; - } - - public long toMillis(final long d) { - return d / (C2 / C1); - } - - public long toSeconds(final long d) { - return d / (C3 / C1); - } - - public long toMinutes(final long d) { - return d / (C4 / C1); - } - - public long toHours(final long d) { - return d / (C5 / C1); - } - - public long toDays(final long d) { - return d / (C6 / C1); - } - - public long convert(final long d, final TimeUnit u) { - return u.toMicros(d); - } - - int excessNanos(final long d, final long m) { - return (int) ((d * C1) - (m * C2)); - } - }, - MILLISECONDS { - public long toNanos(final long d) { - return x(d, C2, Long.MAX_VALUE / (C2)); - } - - public long toMicros(final long d) { - return x(d, C2 / C1, Long.MAX_VALUE / (C2 / C1)); - } - - public long toMillis(final long d) { - return d; - } - - public long toSeconds(final long d) { - return d / (C3 / C2); - } - - public long toMinutes(final long d) { - return d / (C4 / C2); - } - - public long toHours(final long d) { - return d / (C5 / C2); - } - - public long toDays(final long d) { - return d / (C6 / C2); - } - - public long convert(final long d, final TimeUnit u) { - return u.toMillis(d); - } - - int excessNanos(final long d, final long m) { - return 0; - } - }, - SECONDS { - public long toNanos(final long d) { - return x(d, C3, Long.MAX_VALUE / (C3)); - } - - public long toMicros(final long d) { - return x(d, C3 / C1, Long.MAX_VALUE / (C3 / C1)); - } - - public long toMillis(final long d) { - return x(d, C3 / C2, Long.MAX_VALUE / (C3 / C2)); - } - - public long toSeconds(final long d) { - return d; - } - - public long toMinutes(final long d) { - return d / (C4 / C3); - } - - public long toHours(final long d) { - return d / (C5 / C3); - } - - public long toDays(final long d) { - return d / (C6 / C3); - } - - public long convert(final long d, final TimeUnit u) { - return u.toSeconds(d); - } - - int excessNanos(final long d, final long m) { - return 0; - } - }, - MINUTES { - public long toNanos(final long d) { - return x(d, C4, Long.MAX_VALUE / (C4)); - } - - public long toMicros(final long d) { - return x(d, C4 / C1, Long.MAX_VALUE / (C4 / C1)); - } - - public long toMillis(final long d) { - return x(d, C4 / C2, Long.MAX_VALUE / (C4 / C2)); - } - - public long toSeconds(final long d) { - return x(d, C4 / C3, Long.MAX_VALUE / (C4 / C3)); - } - - public long toMinutes(final long d) { - return d; - } - - public long toHours(final long d) { - return d / (C5 / C4); - } - - public long toDays(final long d) { - return d / (C6 / C4); - } - - public long convert(final long d, final TimeUnit u) { - return u.toMinutes(d); - } - - int excessNanos(final long d, final long m) { - return 0; - } - }, - HOURS { - public long toNanos(final long d) { - return x(d, C5, Long.MAX_VALUE / (C5)); - } - - public long toMicros(final long d) { - return x(d, C5 / C1, Long.MAX_VALUE / (C5 / C1)); - } - - public long toMillis(final long d) { - return x(d, C5 / C2, Long.MAX_VALUE / (C5 / C2)); - } - - public long toSeconds(final long d) { - return x(d, C5 / C3, Long.MAX_VALUE / (C5 / C3)); - } - - public long toMinutes(final long d) { - return x(d, C5 / C4, Long.MAX_VALUE / (C5 / C4)); - } - - public long toHours(final long d) { - return d; - } - - public long toDays(final long d) { - return d / (C6 / C5); - } - - public long convert(final long d, final TimeUnit u) { - return u.toHours(d); - } - - int excessNanos(final long d, final long m) { - return 0; - } - }, - DAYS { - public long toNanos(final long d) { - return x(d, C6, Long.MAX_VALUE / (C6)); - } - - public long toMicros(final long d) { - return x(d, C6 / C1, Long.MAX_VALUE / (C6 / C1)); - } - - public long toMillis(final long d) { - return x(d, C6 / C2, Long.MAX_VALUE / (C6 / C2)); - } - - public long toSeconds(final long d) { - return x(d, C6 / C3, Long.MAX_VALUE / (C6 / C3)); - } - - public long toMinutes(final long d) { - return x(d, C6 / C4, Long.MAX_VALUE / (C6 / C4)); - } - - public long toHours(final long d) { - return x(d, C6 / C5, Long.MAX_VALUE / (C6 / C5)); - } - - public long toDays(final long d) { - return d; - } - - public long convert(final long d, final TimeUnit u) { - return u.toDays(d); - } - - int excessNanos(final long d, final long m) { - return 0; - } - }; - - // Handy constants for conversion methods - static final long C1 = 1000L; - static final long C2 = C1 * 1000L; - static final long C3 = C2 * 1000L; - static final long C4 = C3 * 60L; - static final long C5 = C4 * 60L; - static final long C6 = C5 * 24L; - - - /** - * Scale d by m, checking for overflow. - * This has a short name to make above code more readable. - */ - static long x(final long d, final long m, final long over) { - if (d > over) return Long.MAX_VALUE; - if (d < -over) return Long.MIN_VALUE; - return d * m; - } - - // To maintain full signature compatibility with 1.5, and to improve the - // clarity of the generated javadoc (see 6287639: Abstract methods in - // enum classes should not be listed as abstract), method convert - // etc. are not declared abstract but otherwise act as abstract methods. - - /** - * Convert the given time duration in the given unit to this - * unit. Conversions from finer to coarser granularities - * truncate, so lose precision. For example converting - * 999 milliseconds to seconds results in - * 0. Conversions from coarser to finer granularities - * with arguments that would numerically overflow saturate to - * Long.MIN_VALUE if negative or Long.MAX_VALUE - * if positive. - *

- *

For example, to convert 10 minutes to milliseconds, use: - * TimeUnit.MILLISECONDS.convert(10L, TimeUnit.MINUTES) - * - * @param sourceDuration the time duration in the given sourceUnit - * @param sourceUnit the unit of the sourceDuration argument - * @return the converted duration in this unit, - * or Long.MIN_VALUE if conversion would negatively - * overflow, or Long.MAX_VALUE if it would positively overflow. - */ - public long convert(final long sourceDuration, final TimeUnit sourceUnit) { - throw new RuntimeException("abstract method not implemented"); - } - - /** - * Equivalent to NANOSECONDS.convert(duration, this). - * - * @param duration the duration - * @return the converted duration, - * or Long.MIN_VALUE if conversion would negatively - * overflow, or Long.MAX_VALUE if it would positively overflow. - * @see #convert - */ - public long toNanos(final long duration) { - throw new RuntimeException("abstract method not implemented"); - } - - /** - * Equivalent to MICROSECONDS.convert(duration, this). - * - * @param duration the duration - * @return the converted duration, - * or Long.MIN_VALUE if conversion would negatively - * overflow, or Long.MAX_VALUE if it would positively overflow. - * @see #convert - */ - public long toMicros(final long duration) { - throw new RuntimeException("abstract method not implemented"); - } - - /** - * Equivalent to MILLISECONDS.convert(duration, this). - * - * @param duration the duration - * @return the converted duration, - * or Long.MIN_VALUE if conversion would negatively - * overflow, or Long.MAX_VALUE if it would positively overflow. - * @see #convert - */ - public long toMillis(final long duration) { - throw new RuntimeException("abstract method not implemented"); - } - - /** - * Equivalent to SECONDS.convert(duration, this). - * - * @param duration the duration - * @return the converted duration, - * or Long.MIN_VALUE if conversion would negatively - * overflow, or Long.MAX_VALUE if it would positively overflow. - * @see #convert - */ - public long toSeconds(final long duration) { - throw new RuntimeException("abstract method not implemented"); - } - - /** - * Equivalent to MINUTES.convert(duration, this). - * - * @param duration the duration - * @return the converted duration, - * or Long.MIN_VALUE if conversion would negatively - * overflow, or Long.MAX_VALUE if it would positively overflow. - * @see #convert - * @since 1.6 - */ - public long toMinutes(final long duration) { - throw new RuntimeException("abstract method not implemented"); - } - - /** - * Equivalent to HOURS.convert(duration, this). - * - * @param duration the duration - * @return the converted duration, - * or Long.MIN_VALUE if conversion would negatively - * overflow, or Long.MAX_VALUE if it would positively overflow. - * @see #convert - * @since 1.6 - */ - public long toHours(final long duration) { - throw new RuntimeException("abstract method not implemented"); - } - - /** - * Equivalent to DAYS.convert(duration, this). - * - * @param duration the duration - * @return the converted duration - * @see #convert - * @since 1.6 - */ - public long toDays(final long duration) { - throw new RuntimeException("abstract method not implemented"); - } - - /** - * Utility to compute the excess-nanosecond argument to wait, - * sleep, join. - * - * @param d the duration - * @param m the number of milliseconds - * @return the number of nanoseconds - */ - abstract int excessNanos(long d, long m); - - /** - * Not supported in this implementation. - * - * @param obj - * @param timeout - * @throws InterruptedException - */ - public void timedWait(final Object obj, final long timeout) { - throw new RuntimeException("not supported"); - } -} \ No newline at end of file diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/compat/README.eclipse b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/compat/README.eclipse deleted file mode 100644 index 74bccd03226..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/compat/README.eclipse +++ /dev/null @@ -1,24 +0,0 @@ -== Attention Eclipse (m2e or m2eclipse) Users == - -The build configuration that Maven Integration for Eclipse creates from this -POM yields an Eclipse project that won't compile. Here's how you fix it: - -In the Package Explorer view: - - - Expand src/main/java - - Right click on the parent folder of this README - (which is errai-ioc > src/main/java > org.jboss.errai.ioc.compat) - - From the popup menu, choose Build Path -> Exclude - -The project should now compile, and dependent projects in your workspace -should now also build cleanly. - -Note that you will have to repeat these steps every time you perform M2E's -Update Project Configuration feature. - - -== Attention Errai Maintainers == - -The placement of this file in this directory is not an accident: without it, -the item that needs to be right-clicked upon does not exist in the Eclipse -Package Explorer view (empty packages are collapsed by default). diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/compat/javax/annotation/processing/Generated.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/compat/javax/annotation/processing/Generated.java deleted file mode 100644 index 56aa36f7114..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/compat/javax/annotation/processing/Generated.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2005-2013 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ - -package javax.annotation.processing; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.ANNOTATION_TYPE; -import static java.lang.annotation.ElementType.CONSTRUCTOR; -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.LOCAL_VARIABLE; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.PACKAGE; -import static java.lang.annotation.ElementType.PARAMETER; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.SOURCE; - -/** - * The Generated annotation is used to mark source code that has been generated. - * It can also be used to differentiate user written code from generated code - * in a single file. When used, the value element must have the name of the - * code generator. The recommended convention is to use the fully qualified - * name of the code generator in the value field . - *

For example: com.company.package.classname. - * The date element is used to indicate the date the source was generated. - * The date element must follow the ISO 8601 standard. For example the date - * element would have the following value 2001-07-04T12:08:56.235-0700 - * which represents 2001-07-04 12:08:56 local time in the U.S. Pacific - * Time time zone.

- *

The comment element is a place holder for any comments that the code - * generator may want to include in the generated code.

- * - * @since Common Annotations 1.0 - */ - -@Documented -@Retention(SOURCE) -@Target({PACKAGE, TYPE, ANNOTATION_TYPE, METHOD, CONSTRUCTOR, FIELD, - LOCAL_VARIABLE, PARAMETER}) -public @interface Generated { - /** - * The value element MUST have the name of the code generator. - * The recommended convention is to use the fully qualified name of the - * code generator. For example: com.acme.generator.CodeGen. - */ - String[] value(); - - /** - * Date when the source was generated. - */ - String date() default ""; - - /** - * A place holder for any comments that the code generator may want to - * include in the generated code. - */ - String comments() default ""; -} - diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/DeploymentContext.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/DeploymentContext.java deleted file mode 100644 index dc02a9fca69..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/DeploymentContext.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * 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 org.jboss.errai.common.metadata; - -import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * DeploymentContext and {@link DeploymentContextUtil} - * identify and unpack nested subdeployments (i.e. WAR inside EAR) before passing the resulting URL's to - * the Reflections implementation. - *

- * Calling {@link #close()} deletes the temporary created archive files. - * Subsequent call to Reflection rely on classloading and don't need these artifacts anymore. - * - * @author Heiko Braun - */ -class DeploymentContext { - private final List configUrls; - private final Map subContexts = new HashMap<>(); - private final Set processedUrls = new HashSet<>(); - private final Set createdTmpFiles = new HashSet<>(); - - private final Logger log = LoggerFactory.getLogger(DeploymentContext.class); - - DeploymentContext(List configUrls) { - this.configUrls = configUrls; - } - - List getConfigUrls() { - return configUrls; - } - - Map getSubContexts() { - return subContexts; - } - - boolean hasProcessed(File file) { - return processedUrls.contains(file.getAbsolutePath()); - } - - void markProcessed(File file) { - processedUrls.add(file.getAbsolutePath()); - } - - void markTmpFile(File file) { - createdTmpFiles.add(file); - } - - List process() { - DeploymentContextUtil.process(this); - - final List superAndSubContexts = new ArrayList<>(); - - for (final Map.Entry entry : subContexts.entrySet()) { - final File unzipped = entry.getValue(); - try { - superAndSubContexts.add(unzipped.toURI().toURL()); - } - catch (final MalformedURLException e) { - throw new RuntimeException(e); - } - } - - // orig urls needed? could be refactored... - superAndSubContexts.addAll(configUrls); - return superAndSubContexts; - } - - void close() { - for (final File f : createdTmpFiles) { - final boolean deleted = deleteDirectory(f); - if (!deleted) { - //note: use an error message instead of an exception - log.error("failed to cleanup: files were not deleted: " + f.getPath() + " (exists:" + f.exists() + ")"); - } - } - } - - private static boolean deleteDirectory(File path) { - if (path.exists()) { - final File[] files = path.listFiles(); - if (files != null) { - for (int i = 0; i < files.length; i++) { - if (files[i].isDirectory()) { - deleteDirectory(files[i]); - } - else { - files[i].delete(); - } - } - } - } - return (path.delete()); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/DeploymentContextUtil.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/DeploymentContextUtil.java deleted file mode 100644 index 4d46be89279..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/DeploymentContextUtil.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * 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 org.jboss.errai.common.metadata; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.net.URL; -import java.util.UUID; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A set of utilities for processing a {@link DeploymentContext} - * - * @author Heiko Braun - */ -class DeploymentContextUtil { - private static final Logger log = LoggerFactory.getLogger("ClasspathScanning"); - - static File identifyDeployment(final URL url) { - String actualFilePath = url.getPath(); - if (actualFilePath.startsWith("file:")) { - actualFilePath = actualFilePath.substring(5); - } - - final int nestedSeparator = actualFilePath.indexOf('!'); - if (nestedSeparator != -1) { - actualFilePath = actualFilePath.substring(0, nestedSeparator); - } - - log.debug("scanning inside: " + actualFilePath); - - return findActualDeploymentFile(new File(actualFilePath)); - } - - static void process(final DeploymentContext ctx) { - for (final URL url : ctx.getConfigUrls()) { - final File file = DeploymentContextUtil.identifyDeployment(url); - - /* - * several config urls may derive from the same archive - * don't process them twice - */ - if (!ctx.hasProcessed(file)) { - ctx.markProcessed(file); - if (file.getName().endsWith(".ear")){ - DeploymentContextUtil.processNestedZip(file, ctx); - } - } - } - } - - private static File findActualDeploymentFile(File start) { - int pivotPoint; - String rootPath = start.getPath(); - - do { - start = new File(rootPath); - rootPath = rootPath.substring(0, (pivotPoint = rootPath.lastIndexOf(File.separator)) < 0 ? 0 : pivotPoint); - } - while (!start.exists() && pivotPoint > 0); - - return start; - } - - private static void processNestedZip(final File file, final DeploymentContext ctx) { - try { - if (file.getName().matches(".+\\.(ear|war|sar)$") && !file.isDirectory()) // process only certain deployment types - { - if (file.getName().endsWith(".war")) - ctx.getSubContexts().put(file.getName(), file); // WEB-INF/classes - - final ZipInputStream zipFile = new ZipInputStream(new FileInputStream(file)); - ZipEntry zipEntry; - - try { - while ((zipEntry = zipFile.getNextEntry()) != null) { - if (zipEntry.getName().matches(".+\\.(zip|jar|war)$")) // expand nested zip archives - { - if (!ctx.getSubContexts().containsKey(zipEntry.getName())) { - final File tmpUnZip = expandZipEntry(zipFile, zipEntry, ctx); - ctx.getSubContexts().put(zipEntry.getName(), tmpUnZip); - processNestedZip(tmpUnZip, ctx); - } - } - } - } - finally { - zipFile.close(); - } - } - } - catch (Exception e) { - throw new RuntimeException("Failed to process nested zip", e); - } - } - - private static File expandZipEntry(final ZipInputStream stream, final ZipEntry entry, final DeploymentContext ctx) { - final String tmpUUID = "erraiBootstrap_" + UUID.randomUUID().toString().replaceAll("\\-", "_"); - final String tmpDir = System.getProperty("java.io.tmpdir") + "/" + tmpUUID; - final int idx = entry.getName().lastIndexOf('/'); - final String tmpFileName = tmpDir + "/" + entry.getName().substring(idx == -1 ? 0 : idx); - - try { - final File tmpDirFile = new File(tmpDir); - if (!tmpDirFile.exists() && !tmpDirFile.mkdirs()) { - throw new RuntimeException("unable to create temporary directory: " + tmpDirFile.getAbsolutePath()); - } - ctx.markTmpFile(tmpDirFile); - - final File newFile = new File(tmpFileName); - - final FileOutputStream outStream = new FileOutputStream(newFile); - final byte[] buf = new byte[1024]; - int read; - while ((read = stream.read(buf)) != -1) { - outStream.write(buf, 0, read); - } - - outStream.flush(); - outStream.close(); - - return newFile; - } - catch (RuntimeException e) { - throw e; - } - catch (Exception e) { - throw new RuntimeException("Error reading from stream", e); - } - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/ErraiAppPropertiesFiles.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/ErraiAppPropertiesFiles.java deleted file mode 100644 index 2f34d28f3de..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/ErraiAppPropertiesFiles.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * 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 org.jboss.errai.common.metadata; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.net.URLDecoder; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Properties; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author Tiago Bento - */ -public class ErraiAppPropertiesFiles { - - private static final Logger log = LoggerFactory.getLogger(ErraiAppPropertiesFiles.class); - - static final String FILE_NAME = "ErraiApp.properties"; - - private static final String META_INF_FILE_NAME = "META-INF/" + FILE_NAME; - - /** - * Returns the URLs of all ErraiApp.properties and META-INF/ErraiApp.properties. - */ - public static List getUrls(final ClassLoader... classLoaders) { - return Stream.of(classLoaders).flatMap(ErraiAppPropertiesFiles::getUrls).collect(Collectors.toList()); - } - - private static Stream getUrls(final ClassLoader classLoader) { - try { - - final List rootDirResources = Collections.list(classLoader.getResources(FILE_NAME)); - final List metaInfResources = Collections.list(classLoader.getResources(META_INF_FILE_NAME)); - - final List allResources = new ArrayList<>(); - allResources.addAll(rootDirResources); - allResources.addAll(metaInfResources); - - logModulesWithErraiAppPropertiesFileInRootDir(rootDirResources); - - return allResources.stream(); - } catch (final IOException e) { - throw new RuntimeException("failed to load " + FILE_NAME + " from classloader", e); - } - } - - public static List getModulesUrls() { - return getModulesUrls(ErraiAppPropertiesFiles.class.getClassLoader()); - } - - static List getModulesUrls(final ClassLoader... classLoader) { - return getUrls(classLoader).stream() - .peek(ErraiAppPropertiesFiles::logUnreadablePropertiesFiles) - .map(ErraiAppPropertiesFiles::getModuleDir) - .distinct() //due to modules containing files both in classpath:/ and classpath:META-INF/ - .map(ErraiAppPropertiesFiles::decodeUrl) - .collect(Collectors.toList()); - } - - static String getModuleDir(final URL url) { - - final String urlString = url.toExternalForm(); - - final int metaInfEndIndex = urlString.indexOf(META_INF_FILE_NAME); - if (metaInfEndIndex > -1) { - return urlString.substring(0, metaInfEndIndex); - } - - final int rootDirEndIndex = urlString.indexOf(FILE_NAME); - if (rootDirEndIndex > -1) { - return urlString.substring(0, rootDirEndIndex); - } - - throw new RuntimeException("URL " + url.toExternalForm() + " is not of a " + FILE_NAME); - } - - private static URL decodeUrl(final String moduleUrlString) { - try { - return new URL(URLDecoder.decode(moduleUrlString.replaceAll("\\+", "%2b"), "UTF-8")); - } catch (final IOException e) { - e.printStackTrace(); - throw new RuntimeException("Failed to scan configuration Url's", e); - } - } - - private static void logUnreadablePropertiesFiles(final URL url) { - try { - try (InputStream stream = url.openStream()) { - new Properties().load(stream); - } - } catch (final IOException e) { - System.err.println("could not read properties file"); - e.printStackTrace(); - } - } - - private static void logModulesWithErraiAppPropertiesFileInRootDir(final List fileUrls) { - fileUrls.stream().map(ErraiAppPropertiesFiles::getModuleDir).forEach(m -> { - log.warn("Module {} contains {} in root dir. Please consider moving it to META-INF/", m, FILE_NAME); - }); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/ErraiPropertyScanner.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/ErraiPropertyScanner.java deleted file mode 100644 index 42d9406351d..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/ErraiPropertyScanner.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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 org.jboss.errai.common.metadata; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Map; -import java.util.Properties; -import java.util.function.Predicate; - -import com.google.common.collect.Multimap; -import org.jboss.errai.reflections.scanners.AbstractScanner; -import org.jboss.errai.reflections.vfs.Vfs; - -public class ErraiPropertyScanner extends AbstractScanner { - - private final Predicate predicate; - - ErraiPropertyScanner(final Predicate predicate) { - this.predicate = predicate; - } - - public boolean acceptsInput(final String file) { - return predicate.test(file); - } - - public void scan(final Vfs.File file) { - try (final InputStream fileInputStream = file.openInputStream()) { - final Properties properties = new Properties(); - properties.load(fileInputStream); - - final Multimap store = getStore(); - for (final Map.Entry entry : properties.entrySet()) { - store.put((String) entry.getKey(), (String) entry.getValue()); - } - } - catch (IOException e) { - throw new RuntimeException("Failed to load properties: " + file.getFullPath(), e); - } - } - - public void scan(final Object cls) { - throw new UnsupportedOperationException(); //shouldn't get here - } - - public Multimap getProperties() { - return getStore(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/ExtendedTypeAnnotationScanner.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/ExtendedTypeAnnotationScanner.java deleted file mode 100644 index 9c82a15946f..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/ExtendedTypeAnnotationScanner.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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 org.jboss.errai.common.metadata; - -import java.lang.annotation.Inherited; -import java.util.Collections; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; - -import javassist.bytecode.ClassFile; -import org.jboss.errai.common.metadata.MetaDataScanner.CacheHolder; -import org.jboss.errai.common.rebind.CacheUtil; -import org.jboss.errai.reflections.adapters.MetadataAdapter; -import org.jboss.errai.reflections.scanners.TypeAnnotationsScanner; - -/** - * @author Mike Brock - */ -public class ExtendedTypeAnnotationScanner extends TypeAnnotationsScanner { - private final CacheHolder cache = CacheUtil.getCache(MetaDataScanner.CacheHolder.class); - - @Override - public void scan(final Object cls) { - final MetadataAdapter adapter = getMetadataAdapter(); - final String className = adapter.getClassName(cls); - - for (final String annotationType : (List) adapter.getClassAnnotationNames(cls)) { - if (acceptResult(annotationType) || - annotationType.equals(Inherited.class.getName())) { // as an exception, accept - // Inherited as well - getStore().put(annotationType, className); - - if (cls instanceof ClassFile) { - Set classes = cache.ANNOTATIONS_TO_CLASS.get(annotationType); - if (classes == null) { - cache.ANNOTATIONS_TO_CLASS.put(annotationType, classes = - Collections.synchronizedSet(new TreeSet())); - } - classes.add(new SortableClassFileWrapper(className, (ClassFile) cls)); - } - } - } - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/MetaDataProcessor.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/MetaDataProcessor.java deleted file mode 100644 index 84b920d5f2b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/MetaDataProcessor.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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 org.jboss.errai.common.metadata; - -public interface MetaDataProcessor { - void process(T context, MetaDataScanner reflections); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/MetaDataScanner.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/MetaDataScanner.java deleted file mode 100644 index 53f0c01cd25..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/MetaDataScanner.java +++ /dev/null @@ -1,316 +0,0 @@ -/* - * 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 org.jboss.errai.common.metadata; - -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.lang.annotation.Annotation; -import java.lang.annotation.Inherited; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.net.URL; -import java.security.MessageDigest; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.PropertyResourceBundle; -import java.util.ResourceBundle; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.Executors; -import java.util.regex.Pattern; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Multimap; -import org.jboss.errai.common.rebind.CacheStore; -import org.jboss.errai.common.rebind.CacheUtil; -import org.jboss.errai.reflections.Configuration; -import org.jboss.errai.reflections.Reflections; -import org.jboss.errai.reflections.scanners.FieldAnnotationsScanner; -import org.jboss.errai.reflections.scanners.MethodAnnotationsScanner; -import org.jboss.errai.reflections.util.ConfigurationBuilder; -import org.jboss.errai.reflections.vfs.Vfs; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Scans component meta data. The scanner creates a {@link DeploymentContext} that identifies nested - * subdeployments (i.e. WAR inside EAR) and processes the resulting archive Url's using the Reflections library. - *

- *

- * The initial set of config URLs (entry points) is discovered through ErraiApp.properties and META-INF/ErraiApp.properties. - * - * @author Heiko Braun - * @author Mike Brock - * @author Christian Sadilek - * @author Max Barkley - */ -public class MetaDataScanner extends Reflections { - - private static final Logger log = LoggerFactory.getLogger(MetaDataScanner.class); - - private static final String EXTENSION_KEY = "errai.class_scanning_extension"; - - private static final ErraiPropertyScanner propScanner = new ErraiPropertyScanner(file -> file.endsWith(".properties")); - - private final Map, Set>> _annotationCache = new HashMap<>(); - - static MetaDataScanner createInstance() { - return createInstance(ErraiAppPropertiesFiles.getModulesUrls()); - } - - public static MetaDataScanner createInstance(final List urls) { - return createInstance(urls, null); - } - - static MetaDataScanner createInstance(final File cacheFile) { - return createInstance(ErraiAppPropertiesFiles.getModulesUrls(), cacheFile); - } - - private static MetaDataScanner createInstance(final List urls, final File cacheFile) { - registerDefaultHandlers(); - - final DeploymentContext ctx = new DeploymentContext(urls); - final List actualUrls = ctx.process(); - - final MetaDataScanner scanner = new MetaDataScanner(actualUrls, cacheFile); - ctx.close(); // needs to be closed after the scanner is created - return scanner; - } - - private MetaDataScanner(final List urls, final File cacheFile) { - super(getConfiguration(urls)); - try { - for (final Class cls : findExtensions()) { - try { - final Vfs.UrlType urlType = cls.asSubclass(Vfs.UrlType.class).newInstance(); - registerTypeHandler(urlType); - log.info("added class scanning extensions: " + cls.getName()); - } catch (final Throwable t) { - throw new RuntimeException("could not load scanner extension: " + cls.getName(), t); - } - } - } catch (final Throwable t) { - t.printStackTrace(); - } - if (cacheFile != null) { - collect(cacheFile); - } else { - scan(); - } - } - - private List> findExtensions() { - - final List> extensions = new ArrayList<>(); - - for (final URL url : getErraiAppPropertiesFilesUrls()) { - InputStream inputStream = null; - try { - inputStream = url.openStream(); - - final ResourceBundle props = new PropertyResourceBundle(inputStream); - - for (final Object o : props.keySet()) { - final String key = (String) o; - - if (key.equals(EXTENSION_KEY)) { - final String clsName = props.getString(key); - - try { - final Class aClass = Thread.currentThread().getContextClassLoader().loadClass(clsName); - extensions.add(aClass.asSubclass(Vfs.UrlType.class)); - } catch (final Throwable t) { - throw new RuntimeException("could not load class scanning extension: " + clsName, t); - } - } - } - - } catch (final IOException e) { - throw new RuntimeException("error reading ErraiApp.properties", e); - } finally { - if (inputStream != null) { - try { - inputStream.close(); - } catch (final IOException e) { - // - } - } - } - } - return extensions; - } - - private static Collection getErraiAppPropertiesFilesUrls() { - final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); - final ClassLoader metaDataScannerClassLoader = MetaDataScanner.class.getClassLoader(); - - return ErraiAppPropertiesFiles.getUrls(contextClassLoader, metaDataScannerClassLoader); - } - - private static Configuration getConfiguration(final List urls) { - return new ConfigurationBuilder().setUrls(urls).setExecutorService(Executors.newFixedThreadPool(2)) - .setScanners(new FieldAnnotationsScanner(), new MethodAnnotationsScanner(), - new ExtendedTypeAnnotationScanner(), propScanner); - } - - private static void registerTypeHandler(final Vfs.UrlType handler) { - Vfs.addDefaultURLTypes(handler); - } - - private static void registerDefaultHandlers() { - final List urlTypes = Vfs.getDefaultUrlTypes(); - urlTypes.add(new WarUrlType()); - urlTypes.add(NoOpUrl.forSuffix(".jnilib")); - urlTypes.add(NoOpUrl.forSuffix(".zip")); - urlTypes.add(NoOpUrl.forSuffix(".pom")); - urlTypes.add(NoOpUrl.forProtocol("bundleresource")); - // thread safe? - Vfs.setDefaultURLTypes(urlTypes); - } - - public Set> getTypesAnnotatedWithExcluding(final Class annotation, - final String excludeRegex) { - final Pattern p = Pattern.compile(excludeRegex); - - final Set result = new HashSet<>(); - final Set types = getStore().getTypesAnnotatedWith(annotation.getName()); - for (final String className : types) { - if (!p.matcher(className).matches()) { - result.add(className); - } - } - - return ImmutableSet.copyOf(forNames(result)); - } - - public Set> getTypesAnnotatedWith(final Class annotation, - final Collection packages) { - final Set> results = new HashSet<>(); - for (final Class cls : getTypesAnnotatedWith(annotation)) { - if (packages.contains(cls.getPackage().getName())) { - results.add(cls); - } - } - return results; - } - - public Set getMethodsAnnotatedWithExcluding(final Class annotation, - final String excludeRegex) { - final Set results = new HashSet<>(); - final Pattern p = Pattern.compile(excludeRegex); - for (final Method method : getMethodsAnnotatedWith(annotation)) { - if (!p.matcher(method.getClass().getName()).matches()) { - results.add(method); - } - } - return results; - } - - public Set getMethodsAnnotatedWith(final Class annotation, - final Collection packages) { - final Set results = new HashSet<>(); - for (final Method method : getMethodsAnnotatedWith(annotation)) { - if (packages.contains(method.getDeclaringClass().getPackage().getName())) { - results.add(method); - } - } - return results; - } - - public Set getFieldsAnnotatedWith(final Class annotation, - final Collection packages) { - final Set results = new HashSet<>(); - for (final Field field : getFieldsAnnotatedWith(annotation)) { - if (packages.contains(field.getDeclaringClass().getPackage().getName())) { - results.add(field); - } - } - return results; - } - - @Override - public Set> getTypesAnnotatedWith(final Class annotation) { - Set> types = _annotationCache.get(annotation); - if (types == null) { - types = new HashSet<>(super.getTypesAnnotatedWith(annotation)); - - if (annotation.isAnnotationPresent(Inherited.class)) { - for (final Class cls : new ArrayList<>(types)) { - types.addAll(getSubTypesOf(cls)); - } - } - - _annotationCache.put(annotation, types); - } - - return types; - } - - public String getHashForTypesAnnotatedWith(final String seed, final Class annotation) { - if (!CacheUtil.getCache(CacheHolder.class).ANNOTATIONS_TO_CLASS.containsKey(annotation.getName())) { - return "0"; - } else { - try { - final MessageDigest md = MessageDigest.getInstance("SHA-256"); - - if (seed != null) { - md.update(seed.getBytes()); - } - - final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - for (final SortableClassFileWrapper classFileWrapper : CacheUtil - .getCache(CacheHolder.class).ANNOTATIONS_TO_CLASS.get(annotation.getName())) { - byteArrayOutputStream.reset(); - final DataOutputStream dataOutputStream = new DataOutputStream(byteArrayOutputStream); - classFileWrapper.getClassFile().write(dataOutputStream); - dataOutputStream.flush(); - md.update(byteArrayOutputStream.toByteArray()); - } - - return RebindUtils.hashToHexString(md.digest()); - - } catch (final Exception e) { - throw new RuntimeException("could not generate hash", e); - } - } - } - - public Multimap getErraiProperties() { - return propScanner.getProperties(); - } - - public static class CacheHolder implements CacheStore { - final Map> ANNOTATIONS_TO_CLASS = new ConcurrentHashMap<>(); - - @Override - public void clear() { - ANNOTATIONS_TO_CLASS.clear(); - } - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/NoOpUrl.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/NoOpUrl.java deleted file mode 100644 index 8e7a1b59ec4..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/NoOpUrl.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * 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 org.jboss.errai.common.metadata; - -import java.net.URL; -import java.util.Collections; -import java.util.function.Predicate; - -import org.jboss.errai.common.client.api.Assert; -import org.jboss.errai.reflections.vfs.Vfs; - -/** - * A trivial URL Type handler for Reflections VFS which matches any classpath - * entry matching a given predicate and returns an empty - * VFS directory. When used with the extension ".jnilib", this helps silence a - * bunch of warnings that happen when you compile an Errai app on a Mac OS X - * JVM. - *

- * Instances are fully immutable and therefore threadsafe. - */ -public final class NoOpUrl implements Vfs.UrlType { - - private final Predicate test; - - public static NoOpUrl forSuffix(final String urlSuffix) { - final Predicate test = new Predicate() { - @Override - public boolean test(final URL url) { - return url.toExternalForm().endsWith(urlSuffix); - } - - @Override - public String toString() { - return "*" + urlSuffix; - } - }; - - return new NoOpUrl(test); - } - - public static NoOpUrl forProtocol(final String protocol) { - final Predicate test = new Predicate() { - @Override - public boolean test(final URL url) { - return url.getProtocol().equals(protocol); - } - - @Override - public String toString() { - return protocol + "://*"; - } - }; - - return new NoOpUrl(test); - } - - /** - * A VFS directory rooted at a given URL which does not contain any entries. - * - * @author Jonathan Fuerth - */ - private static final class EmptyVfsDir implements Vfs.Dir { - private final URL url; - - private EmptyVfsDir(final URL url) { - this.url = url; - } - - @Override - public String getPath() { - return url.getPath(); - } - - @Override - public Iterable getFiles() { - return Collections.emptyList(); - } - - @Override - public void close() { - // no op - } - } - - /** - * Creates a new LeafUrlType that matches URLs using the given predicate.. - * - * @param test Must not be null. - */ - public NoOpUrl(final Predicate test) { - this.test = Assert.notNull(test); - } - - @Override - public boolean matches(final URL url) { - return test.test(url); - } - - @Override - public Vfs.Dir createDir(final URL url) { - return new EmptyVfsDir(url); - } - - @Override - public String toString() { - return test.toString(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/RebindUtils.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/RebindUtils.java deleted file mode 100644 index cf69134ece3..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/RebindUtils.java +++ /dev/null @@ -1,329 +0,0 @@ -/* - * 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 org.jboss.errai.common.metadata; - -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.nio.charset.Charset; -import java.security.MessageDigest; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import com.google.common.io.Files; -import com.google.gwt.core.ext.GeneratorContext; -import com.google.gwt.core.ext.typeinfo.JPackage; -import com.google.gwt.dev.cfg.ModuleDef; -import com.google.gwt.dev.javac.StandardGeneratorContext; -import org.apache.commons.lang3.StringUtils; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public class RebindUtils { - public static final String ERRAI_DEVEL_NOCACHE_PROPERTY = "errai.devel.nocache"; - public static boolean NO_CACHE = Boolean.getBoolean(ERRAI_DEVEL_NOCACHE_PROPERTY); - - private static String hashSeed = "errai21CR2"; - - private static volatile String _tempDirectory; - - public static String getTempDirectory() { - if (_tempDirectory != null) { - return _tempDirectory; - } - - final String useramePortion = System.getProperty("user.name").replaceAll("[^0-9a-zA-Z]", "-"); - final File file = - new File(System.getProperty("java.io.tmpdir") + "/" + useramePortion + "/errai/" + getClasspathHash() + "/"); - - if (!file.exists()) { - // noinspection ResultOfMethodCallIgnored - file.mkdirs(); - } - - return _tempDirectory = file.getAbsolutePath(); - } - - private static final String[] hashableExtensions = { ".java", ".class", ".properties", ".xml" }; - - private static boolean isValidFileType(final String fileName) { - for (final String extension : hashableExtensions) { - if (fileName.endsWith(extension)) - return true; - } - return false; - } - - public static String getClasspathHash() { - try { - final MessageDigest md = MessageDigest.getInstance("SHA-1"); - final String classPath = System.getProperty("java.class.path"); - md.update(hashSeed.getBytes()); - - for (final String p : classPath.split(System.getProperty("path.separator"))) { - _recurseDir(new File(p), new FileVisitor() { - @Override - public void visit(final File f) { - final String fileName = f.getName(); - if (isValidFileType(fileName)) { - md.update(fileName.getBytes()); - final long lastModified = f.lastModified(); - // md.update((byte) ((lastModified >> 56 & 0xFF))); - // md.update((byte) ((lastModified >> 48 & 0xFF))); - // md.update((byte) ((lastModified >> 40 & 0xFF))); - // md.update((byte) ((lastModified >> 32 & 0xFF))); - md.update((byte) ((lastModified >> 24 & 0xFF))); - md.update((byte) ((lastModified >> 16 & 0xFF))); - md.update((byte) ((lastModified >> 8 & 0xFF))); - md.update((byte) ((lastModified & 0xFF))); - - final long length = f.length(); - // - // md.update((byte) ((length >> 56 & 0xFF))); - // md.update((byte) ((length >> 48 & 0xFF))); - // md.update((byte) ((length >> 40 & 0xFF))); - // md.update((byte) ((length >> 32 & 0xFF))); - md.update((byte) ((length >> 24 & 0xFF))); - md.update((byte) ((length >> 16 & 0xFF))); - md.update((byte) ((length >> 8 & 0xFF))); - md.update((byte) ((length & 0xFF))); - } - } - }); - } - - return hashToHexString(md.digest()); - } - catch (final Exception e) { - throw new RuntimeException("failed to generate hash for classpath fingerprint", e); - } - } - - public static String hashToHexString(final byte[] hash) { - final StringBuilder hexString = new StringBuilder(); - for (final byte b : hash) { - hexString.append(Integer.toHexString(0xFF & b)); - } - return hexString.toString(); - } - - public static File getErraiCacheDir() { - String cacheDir = System.getProperty("errai.devel.debugCacheDir"); - if (cacheDir == null) - cacheDir = new File(".errai/").getAbsolutePath(); - final File fileCacheDir = new File(cacheDir); - // noinspection ResultOfMethodCallIgnored - fileCacheDir.mkdirs(); - return fileCacheDir; - } - - /** - * Writes the given Java class source to a file in the correct package subdirectory within the directory returned by - * {@link #getErraiCacheDir()}. - * - * @param packageName - * The package name of the Java class. - * @param simpleClassName - * The simple name of the Java class. - * @param source - * The source of the Java class. - */ - public static void writeStringToJavaSourceFileInErraiCacheDir(final String packageName, final String simpleClassName, final String source) { - final File dir = new File(getErraiCacheDir() + File.separator + packageName.replace('.', File.separatorChar)); - dir.mkdirs(); - final File sourceFile = new File(dir, simpleClassName + ".java"); - - writeStringToFile(sourceFile, source); - } - - public static void writeStringToFile(final File file, final String data) { - try { - final OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(file, false)); - outputStream.write(data.getBytes("UTF-8")); - outputStream.close(); - } - catch (final IOException e) { - throw new RuntimeException("could not write file for debug cache", e); - } - } - - public static String readFileToString(final File file) { - try { - return Files.toString(file, Charset.forName("UTF-8")); - } - catch (final IOException e) { - throw new RuntimeException("could not read file for debug cache", e); - } - } - - public static String packageNameToDirName(final String pkg) { - final StringBuilder sb = new StringBuilder(); - for (int i = 0; i < pkg.length(); i++) { - if (pkg.charAt(i) == '.') { - sb.append(File.separator); - } - else { - sb.append(pkg.charAt(i)); - } - } - return sb.toString(); - } - - private interface FileVisitor { - public void visit(File f); - } - - private static void _recurseDir(final File f, final FileVisitor visitor) { - if (f.isDirectory()) { - for (final File file : f.listFiles()) { - _recurseDir(file, visitor); - } - } - else { - visitor.visit(f); - } - } - - private static ModuleDef getModuleDef(final GeneratorContext context) { - final StandardGeneratorContext standardGeneratorContext = - (StandardGeneratorContext) context; - try { - final Field moduleField = StandardGeneratorContext.class.getDeclaredField("module"); - moduleField.setAccessible(true); - return (ModuleDef) moduleField.get(standardGeneratorContext); - } - catch (final Throwable t) { - try { - // for GWT versions higher than 2.5.1 we need to get the ModuleDef out of the - // CompilerContext - final Field compilerContextField = StandardGeneratorContext.class.getDeclaredField("compilerContext"); - compilerContextField.setAccessible(true); - // Using plain Object because CompilerContext doesn't exist in GWT 2.5 - final Object compilerContext = compilerContextField.get(standardGeneratorContext); - final Method getModuleMethod = compilerContext.getClass().getMethod("getModule"); - return (ModuleDef) getModuleMethod.invoke(compilerContext); - } - catch (final Throwable t2) { - throw new RuntimeException("could not get module definition (you may be using an incompatible GWT version)", t); - } - } - } - - public static Set getAllModuleXMLs(final GeneratorContext context) { - final ModuleDef moduleDef = getModuleDef(context); - - try { - final Field gwtXmlFilesField = ModuleDef.class.getDeclaredField("gwtXmlFiles"); - gwtXmlFilesField.setAccessible(true); - return (Set) gwtXmlFilesField.get(moduleDef); - } - catch (final Throwable t) { - throw new RuntimeException("could not access 'gwtXmlFiles' field from the module definition " + - "(you may be using an incompatible GWT version)"); - } - } - - public static Set getInheritedModules(final GeneratorContext context) { - final ModuleDef moduleDef = getModuleDef(context); - - try { - final Field inheritedModules = ModuleDef.class.getDeclaredField("inheritedModules"); - inheritedModules.setAccessible(true); - return (Set) inheritedModules.get(moduleDef); - } - catch (final Throwable t) { - throw new RuntimeException("could not access 'inheritedModules' field from the module definition " + - "(you may be using an incompatible GWT version)"); - } - } - - public static boolean isModuleInherited(final GeneratorContext context, final String moduleName) { - return getInheritedModules(context).contains(moduleName); - } - - public static Set getReloadablePackageNames(final GeneratorContext context) { - final Set result = new HashSet(); - final ModuleDef module = getModuleDef(context); - if (module == null) { - return result; - } - - final String moduleName = module.getCanonicalName().replace(".JUnit", ""); - result.add(StringUtils.substringBeforeLast(moduleName, ".")); - - final List dottedModulePaths = new ArrayList(); - for (final File moduleXmlFile : getAllModuleXMLs(context)) { - String fileName = moduleXmlFile.getAbsolutePath(); - fileName = fileName.replace(File.separatorChar, '.'); - dottedModulePaths.add(fileName); - } - - for (final String inheritedModule : getInheritedModules(context)) { - for (final String dottedModulePath : dottedModulePaths) { - if (dottedModulePath.contains(inheritedModule)) { - result.add(StringUtils.substringBeforeLast(inheritedModule, ".")); - } - } - } - - return result; - } - - public static String getModuleName(final GeneratorContext context) { - try { - return getModuleDef(context).getCanonicalName(); - } - catch (final Throwable t) { - return null; - } - } - - private static volatile GeneratorContext _lastTranslatableContext; - private static volatile Set _translatablePackagesCache; - - /** - * Returns a list of all translatable packages accessible to the module under compilation - * (including inherited modules). - */ - public static Set findTranslatablePackages(final GeneratorContext context) { - if (context.equals(_lastTranslatableContext) && _translatablePackagesCache != null) { - return _translatablePackagesCache; - } - _lastTranslatableContext = context; - - final JPackage[] jPackages = context.getTypeOracle().getPackages(); - final Set packages = new HashSet(jPackages.length * 2); - for (final JPackage p : jPackages) { - packages.add(p.getName()); - } - - return _translatablePackagesCache = Collections.unmodifiableSet(packages); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/ScannerSingleton.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/ScannerSingleton.java deleted file mode 100644 index 70ce1f81536..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/ScannerSingleton.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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 org.jboss.errai.common.metadata; - -import java.io.File; -import java.util.concurrent.FutureTask; - -import org.jboss.errai.reflections.ReflectionsException; - -/** - * Shared scanner instance used with {@link com.google.gwt.core.ext.Generator}'s - * - * @author Heiko Braun - * @author Mike Brock - */ -public class ScannerSingleton { - - private static volatile MetaDataScanner scanner; - - private static final String ERRAI_REFLECTIONS_CACHE_PROPERTY = "errai.reflections.cache"; - private static final String CACHE_FILE_NAME = RebindUtils.getClasspathHash() + ".cache.xml"; - - private static final Object lock = new Object(); - - private static final FutureTask future = new FutureTask<>(() -> { - - if (erraiReflectionsCacheIsEnabled() && cacheFileExists()) { - try { - return MetaDataScanner.createInstance(getCacheFile()); - } catch (final ReflectionsException e) { - e.printStackTrace(); - } - } - - return MetaDataScanner.createInstance(); - }); - - - static { - new Thread(future).start(); - } - - - public static MetaDataScanner getOrCreateInstance() { - synchronized (lock) { - if (scanner == null) { - try { - scanner = future.get(); - - if (scanner != null && erraiReflectionsCacheIsEnabled()) { - scanner.save(getCacheFile().getAbsolutePath()); - } - } - catch (Throwable t) { - t.printStackTrace(); - throw new RuntimeException("failed to load class metadata", t); - } - } - return scanner; - } - } - - private static boolean erraiReflectionsCacheIsEnabled() { - return Boolean.getBoolean(ERRAI_REFLECTIONS_CACHE_PROPERTY); - } - - private static File getCacheFile() { - return new File(RebindUtils.getErraiCacheDir(), CACHE_FILE_NAME).getAbsoluteFile(); - } - - private static boolean cacheFileExists() { - return getCacheFile().exists(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/SortableClassFileWrapper.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/SortableClassFileWrapper.java deleted file mode 100644 index 68c5e1ad9e6..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/SortableClassFileWrapper.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 org.jboss.errai.common.metadata; - -import javassist.bytecode.ClassFile; - -/** -* @author Mike Brock -*/ -class SortableClassFileWrapper implements Comparable { - private String name; - private ClassFile classFile; - - SortableClassFileWrapper(final String name, final ClassFile classFile) { - this.name = name; - this.classFile = classFile; - } - - public ClassFile getClassFile() { - return classFile; - } - - @Override - public int compareTo(final SortableClassFileWrapper o) { - return name.compareTo(o.name); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/WarUrlType.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/WarUrlType.java deleted file mode 100644 index 5e33d9038a8..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/metadata/WarUrlType.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 org.jboss.errai.common.metadata; - -import java.io.File; -import java.net.URL; - -import org.jboss.errai.reflections.vfs.SystemDir; -import org.jboss.errai.reflections.vfs.Vfs; -import org.jboss.errai.reflections.vfs.ZipDir; - -/** - * An {@link Vfs.UrlType} for scanning web application archives. - * It simply delegates to {@link SystemDir} and - * {@link ZipDir} respectively - * - * @author Heiko Braun - */ -public class WarUrlType implements Vfs.UrlType { - public boolean matches(final URL url) { - return url.getProtocol().equals("file") && url.toExternalForm().endsWith(".war"); - } - - public Vfs.Dir createDir(final URL url) { - final File file = new File(url.toExternalForm()); - - if (file.isDirectory()) - return new SystemDir(url); - else - return new ZipDir(url); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/rebind/CacheStore.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/rebind/CacheStore.java deleted file mode 100644 index 5866c7ae323..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/rebind/CacheStore.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 org.jboss.errai.common.rebind; - -/** - * @author Mike Brock - */ -public interface CacheStore { - public void clear(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/rebind/CacheUtil.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/rebind/CacheUtil.java deleted file mode 100644 index fbb0d98c528..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/rebind/CacheUtil.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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 org.jboss.errai.common.rebind; - -import java.util.HashMap; -import java.util.Map; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author Mike Brock - */ -public abstract class CacheUtil { - private static final Logger log = LoggerFactory.getLogger(CacheUtil.class); - - private CacheUtil() { - } - - private static final Map, CacheStore> CACHE_STORE_MAP - = new HashMap, CacheStore>(); - - public static T getCache(final Class type) { - synchronized (type) { - T cacheStore = (T) CACHE_STORE_MAP.get(type); - if (cacheStore == null) { - try { - cacheStore = type.newInstance(); - CACHE_STORE_MAP.put(type, cacheStore); - } - catch (Throwable e) { - throw new RuntimeException("failed to instantiate new type: " + type.getName(), e); - } - } - - return cacheStore; - } - } - - public static synchronized void clearAll() { - log.info("clearing all generation caches..."); - - for (Map.Entry, CacheStore> entry : CACHE_STORE_MAP.entrySet()) { - synchronized (entry.getKey()) { - entry.getValue().clear(); - } - } - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/rebind/ClassListReader.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/rebind/ClassListReader.java deleted file mode 100644 index dbe1f102c78..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/rebind/ClassListReader.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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 org.jboss.errai.common.rebind; - -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.HashSet; -import java.util.Set; - -/** - * @author Mike Brock - */ -public class ClassListReader { - public static Set getClassSetFromFile(final File file) { - - try (InputStream inputStream = new BufferedInputStream(new FileInputStream(file))) { - - final byte[] buf = new byte[1024]; - int read; - - final Set classSet = new HashSet(); - final StringBuilder strBuf = new StringBuilder(64); - - while ((read = inputStream.read(buf)) != -1) { - for (int i = 0; i < read; i++) { - switch (buf[i]) { - case '\n': - classSet.add(strBuf.toString().trim()); - strBuf.delete(0, strBuf.length()); - break; - default: - strBuf.append((char) buf[i]); - break; - } - } - } - - if (strBuf.length() > 0) { - classSet.add(strBuf.toString().trim()); - } - - return classSet; - - } - catch (IOException e) { - throw new RuntimeException("could not load file", e); - } - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/rebind/ModuleAnnotationProcessor.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/rebind/ModuleAnnotationProcessor.java deleted file mode 100644 index 08aa5afbe75..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/rebind/ModuleAnnotationProcessor.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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 org.jboss.errai.common.rebind; - -import java.io.IOException; -import java.io.Writer; -import java.util.HashSet; -import java.util.Set; - -import javax.annotation.processing.AbstractProcessor; -import javax.annotation.processing.RoundEnvironment; -import javax.annotation.processing.SupportedAnnotationTypes; -import javax.lang.model.SourceVersion; -import javax.lang.model.element.Element; -import javax.lang.model.element.TypeElement; -import javax.tools.FileObject; -import javax.tools.StandardLocation; - -/** - * @author Mike Brock - */ -@SupportedAnnotationTypes("*") -public class ModuleAnnotationProcessor extends AbstractProcessor { - - final Set allKnownElements = new HashSet(); - - @Override - public boolean process(final Set typeElements, - final RoundEnvironment roundEnvironment) { - - allKnownElements.addAll(roundEnvironment.getRootElements()); - - if (roundEnvironment.processingOver()) { - final StringBuilder builder = new StringBuilder(); - for (final Element e : allKnownElements) { - builder.append(e.toString()).append('\n'); - } - - try { - final FileObject fo - = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", "classlist.mf"); - - try (final Writer writer = fo.openWriter()) { - writer.write(builder.toString()); - } - } - catch (final IOException e) { - e.printStackTrace(); - } - - } - return false; - } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } -} \ No newline at end of file diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/rebind/NameUtil.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/rebind/NameUtil.java deleted file mode 100644 index c1e8af90f77..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/rebind/NameUtil.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * 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 org.jboss.errai.common.rebind; - -/** - * Utility methods for naming generated classes. - * - * @author Max Barkley - */ -public class NameUtil { - - /** - * @return The given fully qualified class name with underscores replacing - * character not allowed in identifiers. - */ - public static String derivedIdentifier(final String fullyQualifiedClassName) { - return fullyQualifiedClassName.replace('.', '_').replace('$', '_'); - } - - /** - * @param derivdedIdentifier A value returned from {@link #derivedIdentifier(String)}. - * @return The derivedIdentifier with package parts shortened to initials. - */ - public static String shortenDerivedIdentifier(final String derivdedIdentifier) { - return shortenDerivedIdentifier(derivdedIdentifier, "_"); - } - - private static String shortenDerivedIdentifier(final String derivedIdentifier, final String delimiter) { - final String[] parts = derivedIdentifier.split(delimiter); - final StringBuilder builder = new StringBuilder(); - boolean haveSeenUpperCase = false; - for (final String part : parts) { - if (haveSeenUpperCase || Character.isUpperCase(part.charAt(0))) { - builder.append(part); - haveSeenUpperCase = true; - } - else { - builder.append(part.charAt(0)); - } - builder.append('_'); - } - builder.delete(builder.length() - 1, builder.length()); - - return builder.toString(); - } - - /** - * @return A compact String representation of the given object's hashCode, using only characters in the ranges - * 'A'-'Z', 'a'-'z', '0'-'9', '_', and '$'. - */ - public static String getShortHashString(final Object obj) { - return getShortHashString(obj.hashCode()); - } - - /** - * @return A compact String representation of the given hashCode, using only characters in the ranges - * 'A'-'Z', 'a'-'z', '0'-'9', '_', and '$'. - */ - public static String getShortHashString(final int hashCode) { - int remaining = hashCode; - final StringBuilder builder = new StringBuilder(6); - for (int i = 0; i < 6; i++) { - final int part = remaining & 0b111111; - builder.append(getHashChar(part)); - remaining = (remaining >> 6); - } - - return builder.toString(); - } - - static char getHashChar(int part) { - if (part <= 'Z' - 'A') { - return (char) ('A' + part); - } - else { - part -= 1 + ('Z' - 'A'); - if (part <= 'z' - 'a') { - return (char) ('a' + part); - } - else { - part -= 1 + ('z' - 'a'); - if (part <= '9' - '0') { - return (char) ('0' + part); - } - else { - part -= 1 + ('9' - '0'); - if (part == 0) { - return '$'; - } - else if (part == 1) { - return '_'; - } - else { - throw new IllegalArgumentException("Argument [part] should satisfy [0 <= part < 64], but [part = " + part + "]."); - } - } - } - } - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/rebind/UniqueNameGenerator.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/rebind/UniqueNameGenerator.java deleted file mode 100644 index 9a51da9e950..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/rebind/UniqueNameGenerator.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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 org.jboss.errai.common.rebind; - -import com.google.common.collect.HashMultiset; -import com.google.common.collect.Multiset; - -/** - * To be used in conjunction with {@link NameUtil} for generating unique - * identifier names for fully qualified class names. - * - * @author Max Barkley - */ -public class UniqueNameGenerator { - - private final Multiset usedNames = HashMultiset.create(); - - /** - * @param name - * An identifier that does not end with an underscore followed by an - * integer. If the name has such an ending, the return value is not - * guaranteed to be unique. - * @return A unique name (will have a number appended to the end if the given - * name has been used before). - */ - public String uniqueName(final String name) { - final String uniqueName; - - final int collisions = usedNames.count(name); - if (collisions > 0) { - uniqueName = name + "_" + String.valueOf(collisions); - } else { - uniqueName = name; - } - usedNames.add(name); - - return uniqueName; - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/server/CacheManifestServlet.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/server/CacheManifestServlet.java deleted file mode 100644 index ced2253805b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/server/CacheManifestServlet.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * 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 org.jboss.errai.common.server; - -import java.io.File; -import java.io.FilenameFilter; -import java.io.IOException; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.jboss.errai.common.client.api.Assert; - -/** - * This servlet provides a cache manifest file specific to the requesting user - * agent. It responds to .appcache requests and dispatches to user agent - * specific appcache.manifest files (i.e. safari.appcache.manifest). These files - * are generated at compile time by a dedicated linker. See the Errai reference - * guide for details on how to activate this linker. - * - * @author Christian Sadilek - */ -@WebServlet(urlPatterns = "*.appcache") -public class CacheManifestServlet extends HttpServlet { - private static final long serialVersionUID = 1L; - private static final String MANIFEST_FILE_EXTENSION = ".appcache.manifest"; - - // Lazily populated cache for user agent names for which a manifest file - // exists, on a per module basis - private final Map> manifestsPerModule = new ConcurrentHashMap>(); - - @Override - protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - final Pattern pattern = Pattern.compile("/([a-zA-Z0-9_]+)/errai.appcache"); - final Matcher matcher = pattern.matcher(req.getServletPath()); - if (!matcher.find()) { - resp.sendError(HttpServletResponse.SC_NOT_FOUND); - return; - } - - final String module = matcher.group(1); - String userAgentManifestPath = null; - final String referrer = req.getHeader("referer"); - if (referrer != null && referrer.contains("gwt.codesvr")) { - // Serve an empty manifest in development mode. This is not reliable as - // some browser won't send the referer header when requesting the - // manifest. In that case we simply return a 404 (the manifest is not - // needed in dev mode anyway but we try to avoid the error, if possible). - userAgentManifestPath = "/" + module + "/dev.appcache.manifest"; - } - else { - userAgentManifestPath = "/" + module + "/" + getUserAgentManifestName(req, module); - } - - resp.setHeader("Cache-Control", "no-cache"); - resp.setHeader("Pragma", "no-cache"); - resp.setContentType("text/cache-manifest"); - req.getRequestDispatcher(userAgentManifestPath).forward(req, resp); - } - - private String getUserAgentManifestName(HttpServletRequest req, String module) { - final String userAgentHeader = req.getHeader("user-agent").toLowerCase(); - - String agentPrefix = ""; - // Do not change the order of these checks. To verify this, compile a - // nocache.js file in pretty mode and compare the corresponding client-side - // logic provided by GWT. Tested with GWT 2.5 and 2.6. - if (userAgentHeader.contains("opera") && manifestExists("opera", module)) { - agentPrefix = "opera"; - } - else if (userAgentHeader.contains("webkit") && manifestExists("safari", module)) { - agentPrefix = "safari"; - } - else if (userAgentHeader.contains("msie 10") && manifestExists("ie10", module)) { - agentPrefix = "ie10"; - } - else if (userAgentHeader.contains("msie 10") && manifestExists("ie9", module)) { - agentPrefix = "ie9"; - } - else if (userAgentHeader.contains("msie 9") && manifestExists("ie9", module)) { - agentPrefix = "ie9"; - } - else if (userAgentHeader.contains("msie 8") && manifestExists("ie8", module)) { - agentPrefix = "ie8"; - } - else if (userAgentHeader.contains("msie") && manifestExists("ie6", module)) { - agentPrefix = "ie6"; - } - else if (userAgentHeader.contains("msie") && manifestExists("ie8", module)) { - agentPrefix = "ie8"; - } - else if (userAgentHeader.contains("gecko") && manifestExists("gecko1_8", module)) { - agentPrefix = "gecko1_8"; - } - - return agentPrefix + MANIFEST_FILE_EXTENSION; - } - - /** - * Returns the set of user agent names for which a manifest file exists in the - * provided module. - * - * @param module - * the name of the GWT module. Not null. - * @return the user agent names for which a manifest file exists. - */ - private Set getManifestsForModule(String module) { - Assert.notNull(module); - - Set manifests = manifestsPerModule.get(module); - if (manifests == null) { - final String path = getServletContext().getRealPath(module); - final File[] manifestFiles = new File(path).listFiles(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.endsWith(MANIFEST_FILE_EXTENSION); - } - }); - - manifests = new HashSet(); - if (manifestFiles != null) { - for (final File manifestFile : manifestFiles) { - final String name = manifestFile.getName(); - manifests.add(name.replace(MANIFEST_FILE_EXTENSION, "")); - } - } - - manifestsPerModule.put(module, manifests); - } - - return manifests; - } - - /** - * Checks if a user agent specific manifest file exists for the provided - * module. - * - * @param userAgent - * the user agent - * @param module - * the GWT module name - * @return true if the manifest exists, otherwise false. - */ - private boolean manifestExists(String userAgent, String module) { - return getManifestsForModule(module).contains(userAgent); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/server/FilterCacheUtil.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/server/FilterCacheUtil.java deleted file mode 100644 index e42093cef46..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/server/FilterCacheUtil.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.jboss.errai.common.server; - -import java.io.CharArrayWriter; -import java.io.IOException; -import java.io.PrintWriter; - -import javax.servlet.ServletOutputStream; -import javax.servlet.WriteListener; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpServletResponseWrapper; - -/** - * Shared utilities for servlet filters in Errai. - * - * @author Christian Sadilek - */ -public class FilterCacheUtil { - private static final String EXPIRES_HEADER = "Expires"; - private static final String CACHE_CONTROL_HEADER = "Cache-Control"; - private static final String PRAGMA_HEADER = "Pragma"; - - private FilterCacheUtil() {} - - public static HttpServletResponse noCache(final HttpServletResponse response) { - response.setHeader( CACHE_CONTROL_HEADER, "no-cache, no-store, must-revalidate" ); - response.setHeader( PRAGMA_HEADER, "no-cache" ); - response.setDateHeader( EXPIRES_HEADER, 0 ); - return response; - } - - public static CharResponseWrapper getCharResponseWrapper(final HttpServletResponse response) { - return new CharResponseWrapper(response); - } - - public static class CharResponseWrapper extends HttpServletResponseWrapper { - - protected CharArrayWriter charWriter = new CharArrayWriter(); - - protected ServletOutputStream outputStream = new ServletOutputStream() { - - @Override - public boolean isReady() { - return true; - } - - @Override - public void setWriteListener(WriteListener writeListener) { - // no-op - } - - @Override - public void write(int b) throws IOException { - charWriter.write(b); - } - }; - - protected PrintWriter writer = new PrintWriter(charWriter); - - public CharResponseWrapper(final HttpServletResponse response) { - super(response); - } - - @Override - public ServletOutputStream getOutputStream() throws IOException { - return outputStream; - } - - @Override - public PrintWriter getWriter() throws IOException { - return writer; - } - - @Override - public void flushBuffer() throws IOException { - // Don't remove this override! - // When intercepting static content, WAS 8.5.5.5 prematurely calls this - // method to flush the output stream before we can calculate the content - // length (see above). - } - - @Override - public String toString() { - return charWriter.toString(); - } - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/server/api/ErraiBootstrapFailure.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/server/api/ErraiBootstrapFailure.java deleted file mode 100644 index 6324e001f2d..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/server/api/ErraiBootstrapFailure.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 org.jboss.errai.common.server.api; - -/** - * ErraiBootstrapFailure extends the RuntimeException. It is thrown when configurations and/or - * initializations of the server fail - */ -public class ErraiBootstrapFailure extends RuntimeException { - - public ErraiBootstrapFailure() { - super(); - } - - public ErraiBootstrapFailure(String message) { - super(message); - } - - public ErraiBootstrapFailure(String message, Throwable cause) { - super(message, cause); - } - - public ErraiBootstrapFailure(Throwable cause) { - super(cause); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/server/api/ErraiConfig.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/server/api/ErraiConfig.java deleted file mode 100644 index 1661849cefc..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/server/api/ErraiConfig.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 org.jboss.errai.common.server.api; - -import org.jboss.errai.common.client.api.ResourceProvider; - -public interface ErraiConfig { - public void addBinding(Class type, ResourceProvider provider); - - public void addResourceProvider(String name, ResourceProvider provider); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/server/api/ErraiConfigExtension.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/server/api/ErraiConfigExtension.java deleted file mode 100644 index 3c5d06327e1..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/server/api/ErraiConfigExtension.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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 org.jboss.errai.common.server.api; - -public interface ErraiConfigExtension { - public void configure(ErraiConfig config); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/server/api/annotations/ExtensionComponent.java b/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/server/api/annotations/ExtensionComponent.java deleted file mode 100644 index f3211e11473..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/main/java/org/jboss/errai/common/server/api/annotations/ExtensionComponent.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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 org.jboss.errai.common.server.api.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface ExtensionComponent { -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/main/resources/META-INF/ErraiApp.properties b/packages/serverless-workflow-diagram-editor/errai-common/src/main/resources/META-INF/ErraiApp.properties deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/test/java/org/jboss/errai/common/client/dom/elemental2/Elemental2DomUtilTest.java b/packages/serverless-workflow-diagram-editor/errai-common/src/test/java/org/jboss/errai/common/client/dom/elemental2/Elemental2DomUtilTest.java deleted file mode 100644 index d83fa4549f1..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/test/java/org/jboss/errai/common/client/dom/elemental2/Elemental2DomUtilTest.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.dom.elemental2; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import com.google.gwt.junit.GWTMockUtilities; -import com.google.gwt.user.client.Element; -import com.google.gwt.user.client.ui.RootPanel; -import com.google.gwt.user.client.ui.Widget; -import elemental2.dom.HTMLElement; -import elemental2.dom.Node; -import jsinterop.base.Js; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; -import static org.powermock.api.mockito.PowerMockito.verifyStatic; - -/** - * Testing Elemental2DomUtil API. - * @author Guilherme Carreiro - */ -@RunWith(PowerMockRunner.class) -@PrepareForTest({ Elemental2DomUtil.class, RootPanel.class, Js.class }) -public class Elemental2DomUtilTest { - - private Elemental2DomUtil elemental2DomUtil; - - @BeforeClass - public static void setupPreferences() { - // Prevent runtime GWT.create() error at 'content = new SimplePanel()' - GWTMockUtilities.disarm(); - } - - @Before - public void setup() { - elemental2DomUtil = spy(new Elemental2DomUtil() { - - void onAttach(Widget w) { - // fake native - } - }); - } - - @Test - public void testRemoveAllElementChildrenWhenNodeDoesNotHaveAnyChildren() { - - final Node node = Mockito.spy(makeNode()); - - final boolean hadChildren = elemental2DomUtil.removeAllElementChildren(node); - - Mockito.verify(node, Mockito.never()).removeChild(any()); - - assertFalse(hadChildren); - } - - @Test - public void testRemoveAllElementChildrenWhenNodeHasChildren() { - - final Node child1 = mock(Node.class); - final Node child2 = mock(Node.class); - final Node node = Mockito.spy(makeNode(child1, child2)); - - final boolean hadChildren = elemental2DomUtil.removeAllElementChildren(node); - - Mockito.verify(node).removeChild(child1); - Mockito.verify(node).removeChild(child2); - - assertTrue(hadChildren); - } - - @Test - public void testAppendWidgetToElementWhenChildIsAttached() throws Exception { - - final HTMLElement parent = mock(HTMLElement.class); - final HTMLElement widgetElement = mock(HTMLElement.class); - final Widget child = mock(Widget.class); - final Element element = mock(Element.class); - - doReturn(true).when(child).isAttached(); - doReturn(element).when(child).getElement(); - doReturn(widgetElement).when(elemental2DomUtil).asHTMLElement(element); - - mockRootPanel(); - - elemental2DomUtil.appendWidgetToElement(parent, child); - - verify(child).removeFromParent(); - verify(parent).appendChild(widgetElement); - verify(elemental2DomUtil).onAttach(child); - - verifyStatic(RootPanel.class); - RootPanel.detachOnWindowClose(child); - } - - @Test - public void testAppendWidgetToElementWhenChildIsNotAttached() throws Exception { - - final HTMLElement parent = mock(HTMLElement.class); - final HTMLElement widgetElement = mock(HTMLElement.class); - final Widget child = mock(Widget.class); - final Element element = mock(Element.class); - - doReturn(false).when(child).isAttached(); - doReturn(element).when(child).getElement(); - doReturn(widgetElement).when(elemental2DomUtil).asHTMLElement(element); - - mockRootPanel(); - - elemental2DomUtil.appendWidgetToElement(parent, child); - - verify(child, never()).removeFromParent(); - verify(parent).appendChild(widgetElement); - verify(elemental2DomUtil).onAttach(child); - - verifyStatic(RootPanel.class); - RootPanel.detachOnWindowClose(child); - } - - @Test - public void testAsHTMLElementForGWTElement() throws Exception { - - final com.google.gwt.dom.client.Element gwtElement = mock(com.google.gwt.dom.client.Element.class); - final HTMLElement expectedElement = mock(HTMLElement.class); - - mockJsCast(expectedElement, gwtElement); - - final HTMLElement actualElement = elemental2DomUtil.asHTMLElement(gwtElement); - - assertSame(expectedElement, actualElement); - } - - private void mockJsCast(final HTMLElement htmlElement, final Object obj) { - PowerMockito.spy(Js.class); - PowerMockito.doReturn(htmlElement).when(Js.class); - Js.cast(obj); - } - - private void mockRootPanel() { - PowerMockito.mockStatic(RootPanel.class); - } - - private Node makeNode(final Node... nodes) { - - final List nodeList = asArrayList(nodes); - - return new Node() { - { - lastChild = last(nodeList); - } - - public Node removeChild(final Node oldChild) { - - nodeList.remove(oldChild); - lastChild = last(nodeList); - - return oldChild; - } - }; - } - - private Node last(final List nodeList) { - return nodeList.isEmpty() ? null : nodeList.get(nodeList.size() - 1); - } - - private ArrayList asArrayList(final Node[] nodes) { - - final List nodeList = Arrays.asList(nodes); - - return new ArrayList<>(nodeList); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/test/java/org/jboss/errai/common/client/util/Base64Tests.java b/packages/serverless-workflow-diagram-editor/errai-common/src/test/java/org/jboss/errai/common/client/util/Base64Tests.java deleted file mode 100644 index cda72f8661a..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/test/java/org/jboss/errai/common/client/util/Base64Tests.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.util; - -import org.junit.Test; - -import static org.junit.Assert.assertArrayEquals; - -/** - * Tests for the base64 codec. Most of the testing is to ensure that the padding - * logic works properly, since there are special cases for 0, 1, or 2 characters - * of padding in the encoded string. - * - * @author Jonathan Fuerth - */ -public class Base64Tests { - - public void encodeDecodeArray(int length) throws Exception { - byte[] empty = new byte[length]; - for (int i = 0; i < length; i++) { - empty[i] = (byte) (i + 1); - } - String encoded = Base64Util.encode(empty, 0, length); - byte[] decoded = Base64Util.decode(encoded); - assertArrayEquals(empty, decoded); - } - - @Test - public void testEncodeEmptyArray() throws Exception { - encodeDecodeArray(0); - } - - @Test - public void testEncodeArrayLength1() throws Exception { - encodeDecodeArray(1); - } - - @Test - public void testEncodeArrayLength2() throws Exception { - encodeDecodeArray(2); - } - - @Test - public void testEncodeArrayLength3() throws Exception { - encodeDecodeArray(3); - } - - @Test - public void testEncodeArrayLength20() throws Exception { - encodeDecodeArray(20); - } - - @Test - public void testEncodeArrayLength21() throws Exception { - encodeDecodeArray(21); - } - - @Test - public void testEncodeArrayLength22() throws Exception { - encodeDecodeArray(22); - } - - @Test - public void testEncodeArrayLength23() throws Exception { - encodeDecodeArray(23); - } - - @Test - public void testEncodeArrayLength24() throws Exception { - encodeDecodeArray(24); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/test/java/org/jboss/errai/common/client/util/PropertiesTest.java b/packages/serverless-workflow-diagram-editor/errai-common/src/test/java/org/jboss/errai/common/client/util/PropertiesTest.java deleted file mode 100644 index 87cc30524ff..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/test/java/org/jboss/errai/common/client/util/PropertiesTest.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * 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 org.jboss.errai.common.client.util; - -import java.util.Map; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -/** - * - * @author Max Barkley - */ -public class PropertiesTest { - - @Test - public void parsePropertiesWithEquals() { - final String data = "key1=value1\nkey2=value2"; - final Map props = Properties.load(data); - - assertEquals("value1", props.get("key1")); - assertEquals("value2", props.get("key2")); - assertEquals(2, props.size()); - } - - @Test - public void parsePropertiesWithColon() throws Exception { - final String data = "key1:value1\nkey2:value2"; - final Map props = Properties.load(data); - - assertEquals("value1", props.get("key1")); - assertEquals("value2", props.get("key2")); - assertEquals(2, props.size()); - } - - @Test - public void parsePropertiesWithEqualsAndColon() throws Exception { - final String data = "key1:value1\nkey2=value2"; - final Map props = Properties.load(data); - - assertEquals("value1", props.get("key1")); - assertEquals("value2", props.get("key2")); - assertEquals(2, props.size()); - } - - @Test - public void ignoreSpaceBetweenKeyAndValue() throws Exception { - final String data = "key1 = value1\nkey2= value2\nkey3 =value3"; - final Map props = Properties.load(data); - - assertEquals("value1", props.get("key1")); - assertEquals("value2", props.get("key2")); - assertEquals("value3", props.get("key3")); - assertEquals(3, props.size()); - } - - @Test - public void ignoreCommentLines() throws Exception { - final String data = "key1=value1\n#key2=value2\n!key3=value3"; - final Map props = Properties.load(data); - - assertEquals("value1", props.get("key1")); - assertEquals(1, props.size()); - } - - @Test - public void parseEmpty() throws Exception { - final String data = ""; - final Map props = Properties.load(data); - - assertEquals(0, props.size()); - } - - @Test - public void parseWhitespaceOnly() throws Exception { - final String data = " \n "; - final Map props = Properties.load(data); - - assertEquals(0, props.size()); - } - - @Test - public void includeWhitespaceAfterPropertyValueExceptTerminalNewline() throws Exception { - final String data = "key1=value1 \t\n"; - final Map props = Properties.load(data); - - assertEquals("value1 \t", props.get("key1")); - assertEquals(1, props.size()); - } - - @Test - public void ignoreWhitespaceAfterBackslash() throws Exception { - final String data = "key1=value1\\ \t\n, and value2"; - final Map props = Properties.load(data); - - assertEquals("value1, and value2", props.get("key1")); - assertEquals(1, props.size()); - } - - @Test - public void valueWithReturnNewlineAndTab() throws Exception { - final String data = "key1=value1\\t\\r\\n"; - final Map props = Properties.load(data); - - assertEquals("value1\t\r\n", props.get("key1")); - assertEquals(1, props.size()); - } - - @Test - public void escapeBackslashesBecomeSingleBackslashes() throws Exception { - final String data = "key1=\\\\value1"; - final Map props = Properties.load(data); - - assertEquals("\\value1", props.get("key1")); - assertEquals(1, props.size()); - } - - @Test - public void unicodeValues() throws Exception { - final String data = "key1=value\\u2202"; - final Map props = Properties.load(data); - - assertEquals("value\u2202", props.get("key1")); - assertEquals(1, props.size()); - } - - @Test - public void lineEndingWithReturn() throws Exception { - final String data = "key1=value1\rkey2=value2"; - final Map props = Properties.load(data); - - assertEquals("value1", props.get("key1")); - assertEquals("value2", props.get("key2")); - assertEquals(2, props.size()); - } - - @Test - public void lineEndingWithReturnAndNewline() throws Exception { - final String data = "key1=value1\r\nkey2=value2"; - final Map props = Properties.load(data); - - assertEquals("value1", props.get("key1")); - assertEquals("value2", props.get("key2")); - assertEquals(2, props.size()); - } - - @Test - public void parseValueEndingWithEscapedEquals() { - final String data = "key1=value1\\=\nkey2=value2"; - final Map props = Properties.load(data); - - assertEquals("value1=", props.get("key1")); - assertEquals("value2", props.get("key2")); - assertEquals(2, props.size()); - } - - @Test - public void parseValueEndingWithEscapedTwoPoints() { - final String data = "key1=value1\\:\nkey2=value2"; - final Map props = Properties.load(data); - - assertEquals("value1:", props.get("key1")); - assertEquals("value2", props.get("key2")); - assertEquals(2, props.size()); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/test/java/org/jboss/errai/common/it/CommonTests.gwt.xml b/packages/serverless-workflow-diagram-editor/errai-common/src/test/java/org/jboss/errai/common/it/CommonTests.gwt.xml deleted file mode 100644 index 4b01d70919a..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/test/java/org/jboss/errai/common/it/CommonTests.gwt.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/test/java/org/jboss/errai/common/it/client/StringFormatTests.java b/packages/serverless-workflow-diagram-editor/errai-common/src/test/java/org/jboss/errai/common/it/client/StringFormatTests.java deleted file mode 100644 index 4c9d4025d5c..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/test/java/org/jboss/errai/common/it/client/StringFormatTests.java +++ /dev/null @@ -1,320 +0,0 @@ -/* - * 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 org.jboss.errai.common.it.client; - -import java.util.Date; - -import com.google.gwt.junit.client.GWTTestCase; -import org.jboss.errai.common.client.logging.util.StringFormat; - -/** - * Tests for the {@link StringFormat} class. - * - * Most of these tests verify behaviour identical to - * {@link String#format(String, Object...)}, but in some cases the output - * differs slightly for the convenience of using pre-existing GWT - * implementations. - * - * @author Max Barkley - */ -@SuppressWarnings("deprecation") -public class StringFormatTests extends GWTTestCase { - - public void testScientificNotationLower() throws Exception { - assertEquals("3.141593e00", StringFormat.format("%e", Math.PI)); - } - - public void testScientificNotationUpper() throws Exception { - assertEquals("3.141593E00", StringFormat.format("%E", Math.PI)); - } - - public void testScientificNotationPrecision() throws Exception { - assertEquals("3.14E00", StringFormat.format("%.2E", Math.PI)); - } - - public void testGConversionLower() throws Exception { - assertEquals(StringFormat.format("%e", Math.PI), StringFormat.format("%g", Math.PI)); - } - - public void testGConversionUpper() throws Exception { - assertEquals(StringFormat.format("%E", Math.PI), StringFormat.format("%G", Math.PI)); - } - - // public void testHexScientificNotationLower() throws Exception { - // assertEquals("0x1.921fb54442d18p1", StringFormat.format("%a", Math.PI)); - // } - // - // public void testHexScientificNotationUpper() throws Exception { - // assertEquals("0x1.921FB54442D18P1", StringFormat.format("%A", Math.PI)); - // } - - public void testStringLower() throws Exception { - assertEquals("value", StringFormat.format("%s", "value")); - } - - public void testStringUpper() throws Exception { - assertEquals("VALUE", StringFormat.format("%S", "value")); - } - - public void testStringPrecision() throws Exception { - final String val = "123456789"; - assertEquals(val.substring(0, 3), StringFormat.format("%.3s", val)); - } - - public void testStringWidth() throws Exception { - final String val = "123456789"; - assertEquals(" " + val, StringFormat.format("%10s", val)); - } - - public void testStringNull() throws Exception { - assertEquals("null", StringFormat.format("%s", null)); - } - - public void testInt() throws Exception { - assertEquals("1337", StringFormat.format("%d", 1337)); - } - - public void testBooleanNonNull() throws Exception { - assertEquals("true", StringFormat.format("%b", new Object())); - } - - public void testBooleanUpper() throws Exception { - assertEquals("TRUE", StringFormat.format("%B", new Object())); - } - - public void testBooleanNullUpper() throws Exception { - assertEquals("false", StringFormat.format("%b", null)); - } - - public void testBooleanTrue() throws Exception { - assertEquals("true", StringFormat.format("%b", true)); - } - - public void testBooleanFalse() throws Exception { - assertEquals("false", StringFormat.format("%b", false)); - } - - public void testHexStringLower() throws Exception { - final Object obj = new Object() { - @Override - public int hashCode() { - return 0xabcdef; - } - }; - assertEquals(Integer.toHexString(obj.hashCode()), StringFormat.format("%h", obj)); - } - - public void testHexStringUpper() throws Exception { - final Object obj = new Object() { - @Override - public int hashCode() { - return 0xabcdef; - } - }; - assertEquals(Integer.toHexString(obj.hashCode()).toUpperCase(), StringFormat.format("%H", obj)); - } - - public void testHexStringNull() throws Exception { - assertEquals("null", StringFormat.format("%h", null)); - } - - public void testUnicodeCharacterLower() throws Exception { - assertEquals("c", StringFormat.format("%c", (int) 'c')); - } - - public void testUnicodeCharacterUpper() throws Exception { - assertEquals("C", StringFormat.format("%C", (int) 'c')); - } - - public void testOctal() throws Exception { - assertEquals(Integer.toOctalString(735), StringFormat.format("%o", 735)); - } - - public void testHexIntLower() throws Exception { - assertEquals(Integer.toHexString(725815), StringFormat.format("%x", 725815)); - } - - public void testHexIntUpper() throws Exception { - assertEquals(Integer.toHexString(725815).toUpperCase(), StringFormat.format("%X", 725815)); - } - - /* - * Currently StringFormat.format("%f", 1.0) returns "1" - */ - public void ignoreFloatingPoint() throws Exception { - assertEquals(String.valueOf(1.0), StringFormat.format("%f", 1.0)); - } - - public void testLiteralPercent() throws Exception { - assertEquals("%", StringFormat.format("%%")); - } - - public void testNewline() throws Exception { - assertEquals("\n", StringFormat.format("%n")); - } - - /* - * START DISABLED DATE TESTS - * - * These Date tests are ignored because they break outside of the EST/EDT timezone. - * Unfortunately setting the locale in the GWT module does not seem to work. - */ - public void ignoreLongDate() throws Exception { - final long time = 1000000000; - assertEquals("08:46", StringFormat.format("%tR", time)); - } - - public void ignoreDate() throws Exception { - final Date date = new Date(1000000000); - assertEquals("08:46", StringFormat.format("%tR", date)); - } - - public void ignoreDateUpperT() throws Exception { - final Date date = new Date(1000000000); - assertEquals("08:46:40", StringFormat.format("%tT", date)); - } - - public void ignoreDateLowerR() throws Exception { - final Date date = new Date(1000000000); - assertEquals("08:46:40 AM", StringFormat.format("%tr", date)); - } - - public void ignoreDateUpperD() throws Exception { - final Date date = new Date(1000000000); - assertEquals("01/12/70", StringFormat.format("%tD", date)); - } - - public void ignoreDateUpperF() throws Exception { - final Date date = new Date(1000000000); - assertEquals("1970-01-12", StringFormat.format("%tF", date)); - } - - public void ignoreDateLowerC() throws Exception { - final Date date = new Date(1000000000); - assertEquals("Mon Jan 12 08:46:40 UTC-5 1970", StringFormat.format("%tc", date)); - } - - public void ignoreDateLowerK() throws Exception { - final Date date = new Date(1000000000); - date.setHours(13); - assertEquals("13", StringFormat.format("%tk", date)); - } - - public void ignoreDateLowerL() throws Exception { - final Date date = new Date(1000000000); - assertEquals("8", StringFormat.format("%tl", date)); - } - - public void ignoreDateUpperL() throws Exception { - final Date date = new Date(10000000123L); - assertEquals(String.valueOf(123), StringFormat.format("%tL", date)); - } - - public void ignoreDateUpperN() throws Exception { - final Date date = new Date(1000000123L); - assertEquals("123000000", StringFormat.format("%tN", date)); - } - - public void ignoreDateLowerZ() throws Exception { - final Date date = new Date(1000000000); - assertEquals("-0500", StringFormat.format("%tz", date)); - } - - public void ignoreDateLowerS() throws Exception { - final Date date = new Date(1000000000); - assertEquals(String.valueOf(1000000), StringFormat.format("%ts", date)); - } - - public void ignoreDateUpperQ() throws Exception { - final Date date = new Date(1000000000); - assertEquals(String.valueOf(1000000000), StringFormat.format("%tQ", date)); - } - - public void ignoreDateUpperB() throws Exception { - final Date date = new Date(1000000000); - assertEquals("January", StringFormat.format("%tB", date)); - } - - public void ignoreDateUpperA() throws Exception { - final Date date = new Date(1000000000); - assertEquals("Monday", StringFormat.format("%tA", date)); - } - - public void ignoreDateUpperC() throws Exception { - final Date date = new Date(1000000000); - assertEquals("19", StringFormat.format("%tC", date)); - } - - public void ignoreDateLowerJ() throws Exception { - final Date date = new Date(1000000000); - assertEquals("012", StringFormat.format("%tj", date)); - } - - public void ignoreDateLowerE() throws Exception { - final Date date = new Date(1000000000); - date.setDate(9); - assertEquals("9", StringFormat.format("%te", date)); - } - /* - * END DISABLED DATE TESTS - */ - - public void testMultipleConversions() throws Exception { - final String val1 = "happy"; - final String val2 = "rainbows"; - final String val3 = "bananas"; - - assertEquals(val1 + " " + val2 + " " + val3, StringFormat.format("%s %s %s", val1, val2, val3)); - } - - public void testIndexedConversions() throws Exception { - final String val1 = "happy"; - final String val2 = "rainbows"; - final String val3 = "bananas"; - - assertEquals(val1 + " " + val2 + " " + val3, StringFormat.format("%3$s %1$s %2$s", val2, val3, val1)); - } - - public void testIndexedAndNonIndexedConversions() throws Exception { - final String val1 = "happy"; - final String val2 = "rainbows"; - final String val3 = "bananas"; - - assertEquals(val3 + " " + val1 + " " + val2 + " " + val1, StringFormat.format("%3$s %s %s %1$s", val1, val2, val3)); - } - - public void testInvalidFlagsThrowsException() throws Exception { - // Currently no flags are supported, so check that an exception is thrown - // when any is given - try { - StringFormat.format("%-s", "test"); - fail("An exception should be thrown."); - } - catch (final Exception e) { - } - } - - @Override - public String getModuleName() { - return "org.jboss.errai.common.it.CommonTests"; - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/test/java/org/jboss/errai/common/metadata/ErraiAppPropertiesFilesTest.java b/packages/serverless-workflow-diagram-editor/errai-common/src/test/java/org/jboss/errai/common/metadata/ErraiAppPropertiesFilesTest.java deleted file mode 100644 index 24a56500a59..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/test/java/org/jboss/errai/common/metadata/ErraiAppPropertiesFilesTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.jboss.errai.common.metadata; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.List; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class ErraiAppPropertiesFilesTest { - - @Test - public void testGetUrls() { - final ClassLoader classLoader = ErraiAppPropertiesFilesTest.class.getClassLoader(); - final List urls = ErraiAppPropertiesFiles.getUrls(classLoader); - - // Errai Common has a properties this and Errai Common Test has other two. - assertEquals(3, urls.size()); - } - - @Test - public void testGetModuleUrls() { - final List moduleUrls = ErraiAppPropertiesFiles.getModulesUrls(); - - // Errai Common has a properties this and Errai Common Test has other two, - // but since they together make two modules, only two URLs should be returned. - assertEquals(2, moduleUrls.size()); - } - - @Test - public void testGetModuleDirRootFile() throws MalformedURLException { - final URL url = new URL("file:/foo/bar/ErraiApp.properties/"); - final String moduleDir = ErraiAppPropertiesFiles.getModuleDir(url); - - assertEquals("file:/foo/bar/", moduleDir); - } - - @Test - public void testGetModuleDirMetaInfFile() throws MalformedURLException { - final URL url = new URL("file:/foo/bar/META-INF/ErraiApp.properties/"); - final String moduleDir = ErraiAppPropertiesFiles.getModuleDir(url); - - assertEquals("file:/foo/bar/", moduleDir); - } - - @Test(expected = RuntimeException.class) - public void testGetModuleDirWithInvalidFileName() throws MalformedURLException { - final URL url = new URL("file:/foo/bar/META-INF/InvalidName.properties/"); - ErraiAppPropertiesFiles.getModuleDir(url); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/test/java/org/jboss/errai/common/metadata/MetaDataScannerTest.java b/packages/serverless-workflow-diagram-editor/errai-common/src/test/java/org/jboss/errai/common/metadata/MetaDataScannerTest.java deleted file mode 100644 index c881b16ff90..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/test/java/org/jboss/errai/common/metadata/MetaDataScannerTest.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * 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 org.jboss.errai.common.metadata; - -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; -import java.util.stream.Collectors; - -import org.jboss.errai.reflections.util.ClasspathHelper; -import org.jboss.errai.reflections.vfs.Vfs; -import org.jboss.errai.reflections.vfs.ZipDir; -import org.jboss.shrinkwrap.api.ShrinkWrap; -import org.jboss.shrinkwrap.api.exporter.ZipExporter; -import org.jboss.shrinkwrap.api.spec.JavaArchive; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -/** - * Tests for {@link MetaDataScanner}. - * - * @author Christian Sadilek - */ -public class MetaDataScannerTest { - - @Test - public void testJarUrlDecodingWithSimpleName() throws Exception { - testJarUrlDecoding("test"); - } - - @Test - public void testJarUrlDecodingWithSpecialCharacters() throws Exception { - testJarUrlDecoding("testjar-\u00e4\u00f6\u00e9\u00f8 +abc!@$%^&()_+}{"); - } - - private void testJarUrlDecoding(String jarFileName) throws IOException { - File erraiAppPropertiesFile = new File(System.getProperty("java.io.tmpdir"), ErraiAppPropertiesFiles.FILE_NAME); - erraiAppPropertiesFile.createNewFile(); - - File jarFile = File.createTempFile(jarFileName, ".jar"); - JavaArchive jarArchive = ShrinkWrap.create(JavaArchive.class) - .addClass(getClass()) - .addAsResource(erraiAppPropertiesFile); - jarArchive.as(ZipExporter.class).exportTo(jarFile, true); - - erraiAppPropertiesFile.delete(); - - URL testJarURL = jarFile.toURI().toURL(); - assertNotNull("Jar file not found: " + jarFile, testJarURL); - - ClassLoader loader = URLClassLoader.newInstance(new URL[] { testJarURL }, getClass().getClassLoader()); - List urls = ErraiAppPropertiesFiles.getModulesUrls(loader); - assertFalse("No URLs returned", urls.isEmpty()); - - /* - * Errai Common has a properties file and Errai Common Test has two properties files. - * So that this test is not dependent of the URLs order and it adds a temporary jar to the classpath, - * we search for a URL starting with "jar". - */ - List tempFileAdded = urls.stream() - .filter(url -> url.toExternalForm().startsWith("jar")) - .collect(Collectors.toList()); - - assertEquals(1, tempFileAdded.size()); - URL erraiAppPropertiesTestFile = tempFileAdded.get(0); - - String[] segments = erraiAppPropertiesTestFile.getPath().split("/"); - assertTrue("No path segments found in URL", segments.length > 0); - assertEquals("URL not properly decoded", jarFile.getName() +"!", segments[segments.length - 1]); - assertNotNull("Could not open jar", new ZipDir(erraiAppPropertiesTestFile).getFiles()); - - Set zipContents = new TreeSet<>(); - for (Vfs.File path : new ZipDir(erraiAppPropertiesTestFile).getFiles()) { - if (!path.getRelativePath().endsWith("/")) { - zipContents.add(path.getRelativePath()); - } - } - - Set expectedContents = new TreeSet<>(); - expectedContents.add(ErraiAppPropertiesFiles.FILE_NAME); - expectedContents.add("org/jboss/errai/common/metadata/MetaDataScannerTest.class"); - - assertEquals("Wrong file contents", expectedContents, zipContents); - - // delete if test passes (otherwise, we may want to inspect its contents) - jarFile.delete(); - } - - @Test - public void testClasspathUrlDecoding() throws Exception { - - File erraiAppPropertiesFile = new File(System.getProperty("java.io.tmpdir"), ErraiAppPropertiesFiles.FILE_NAME); - erraiAppPropertiesFile.createNewFile(); - - File jarFile = File.createTempFile("testjar-\u00e4\u00f6\u00e9\u00f8 +abc!@$%^&()_+}{", ".jar"); - JavaArchive jarArchive = ShrinkWrap.create(JavaArchive.class) - .addClass(getClass()) - .addAsResource(erraiAppPropertiesFile); - jarArchive.as(ZipExporter.class).exportTo(jarFile, true); - - erraiAppPropertiesFile.delete(); - - URL testJarURL = jarFile.toURI().toURL(); - assertNotNull("Jar file not found: " + jarFile, testJarURL); - - ClassLoader loader = URLClassLoader.newInstance(new URL[] { testJarURL }, null); - Set urls = ClasspathHelper.forClassLoader(loader); - assertFalse("No URLs returned", urls.isEmpty()); - URL url = urls.iterator().next(); - String[] segments = url.getPath().split("/"); - - assertTrue("No path segments found in URL", segments.length > 0); - assertEquals("URL not properly decoded", jarFile.getName(), segments[segments.length - 1]); - assertNotNull("Could not open jar", new ZipDir(url).getFiles()); - - Set zipContents = new TreeSet<>(); - for (Vfs.File path : new ZipDir(url).getFiles()) { - if (!path.getRelativePath().endsWith("/")) { - zipContents.add(path.getRelativePath()); - } - } - - Set expectedContents = new TreeSet<>(); - expectedContents.add(ErraiAppPropertiesFiles.FILE_NAME); - expectedContents.add("org/jboss/errai/common/metadata/MetaDataScannerTest.class"); - - assertEquals("Wrong file contents", expectedContents, zipContents); - - // delete if test passes (otherwise, we may want to inspect its contents) - jarFile.delete(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/test/java/org/jboss/errai/common/rebind/NameUtilTests.java b/packages/serverless-workflow-diagram-editor/errai-common/src/test/java/org/jboss/errai/common/rebind/NameUtilTests.java deleted file mode 100644 index b9cce4d6d2e..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-common/src/test/java/org/jboss/errai/common/rebind/NameUtilTests.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 org.jboss.errai.common.rebind; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Test; - -import static org.junit.Assert.assertTrue; - -/** - * - * @author Max Barkley - */ -public class NameUtilTests { - - @Test - public void getHashCharIsValidJavaIdentifierCharForWholeDomain() throws Exception { - final Map invalid = new HashMap<>(); - for (int i = 0; i < 64; i++) { - final char observed = NameUtil.getHashChar(i); - if (!Character.isJavaIdentifierPart(observed)) { - invalid.put(i, observed); - } - } - - assertTrue("The following mappings are not valid Java identifier parts: " + invalid, invalid.isEmpty()); - } - - @Test - public void validHashForLargestUnsignedInt() throws Exception { - final String observed = NameUtil.getShortHashString(0xFFFFFFFF); - for (int i = 0; i < observed.length(); i++) { - assertTrue("Invalid identifier part [" + observed + "].", Character.isJavaIdentifierPart(observed.charAt(i))); - } - } - - @Test - public void validHashForLargestSignedInt() throws Exception { - final String observed = NameUtil.getShortHashString(Integer.MAX_VALUE); - for (int i = 0; i < observed.length(); i++) { - assertTrue("Invalid identifier part [" + observed + "].", Character.isJavaIdentifierPart(observed.charAt(i))); - } - } - - @Test - public void validHashForSmallestSignedInt() throws Exception { - final String observed = NameUtil.getShortHashString(Integer.MIN_VALUE); - for (int i = 0; i < observed.length(); i++) { - assertTrue("Invalid identifier part [" + observed + "].", Character.isJavaIdentifierPart(observed.charAt(i))); - } - } - - @Test - public void validHashForZero() throws Exception { - final String observed = NameUtil.getShortHashString(0); - for (int i = 0; i < observed.length(); i++) { - assertTrue("Invalid identifier part [" + observed + "].", Character.isJavaIdentifierPart(observed.charAt(i))); - } - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/test/resources/ErraiApp.properties b/packages/serverless-workflow-diagram-editor/errai-common/src/test/resources/ErraiApp.properties deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/packages/serverless-workflow-diagram-editor/errai-common/src/test/resources/META-INF/ErraiApp.properties b/packages/serverless-workflow-diagram-editor/errai-common/src/test/resources/META-INF/ErraiApp.properties deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/packages/serverless-workflow-diagram-editor/errai-config/pom.xml b/packages/serverless-workflow-diagram-editor/errai-config/pom.xml deleted file mode 100644 index a498c4d63ad..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-config/pom.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - org.kie.kogito.stunner.serverless.editor - stunner-editors-parent - ${revision} - - - 4.0.0 - errai-config - Errai::Config - - - - - org.kie.kogito.stunner.serverless.editor - errai-codegen - provided - - - - org.kie.kogito.stunner.serverless.editor - errai-codegen-gwt - provided - - - - javax.enterprise - cdi-api - provided - - - - org.kie.kogito.stunner.serverless.editor - errai-common - - - - org.gwtproject - gwt-dev - provided - - - org.eclipse.jetty - jetty-annotations - - - - - diff --git a/packages/serverless-workflow-diagram-editor/errai-config/src/main/java/org/jboss/errai/config/rebind/AbstractAsyncGenerator.java b/packages/serverless-workflow-diagram-editor/errai-config/src/main/java/org/jboss/errai/config/rebind/AbstractAsyncGenerator.java deleted file mode 100644 index 72e5d7bceab..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-config/src/main/java/org/jboss/errai/config/rebind/AbstractAsyncGenerator.java +++ /dev/null @@ -1,262 +0,0 @@ -/* - * 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 org.jboss.errai.config.rebind; - -import java.io.PrintWriter; -import java.util.Collection; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.Callable; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.Future; - -import com.google.gwt.core.ext.Generator; -import com.google.gwt.core.ext.GeneratorContext; -import com.google.gwt.core.ext.TreeLogger; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.common.metadata.RebindUtils; -import org.jboss.errai.config.util.ThreadUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Base class of all asynchronous code generators. - * - * @author Christian Sadilek - */ -public abstract class AbstractAsyncGenerator extends Generator implements AsyncCodeGenerator { - - private static final Map, String> cacheMap = new ConcurrentHashMap, String>(); - private static final Map, Set> cacheRelevantClasses = - new ConcurrentHashMap, Set>(); - - private static Logger log = LoggerFactory.getLogger(AbstractAsyncGenerator.class); - - @Override - public Future generateAsync(final TreeLogger logger, final GeneratorContext context) { - return ThreadUtil.submit(new Callable() { - @Override - public String call() throws Exception { - final String generatedCode; - - if (isCacheEnabled() && isCacheValid()) { - log.info("Using cached output from " + AbstractAsyncGenerator.this.getClass().getName()); - generatedCode = getGeneratedCache(); - } - else { - log.info("Running generator " + AbstractAsyncGenerator.this.getClass().getName()); - clearCacheRelevantClasses(); - generatedCode = generate(logger, context); - setGeneratedCache(generatedCode); - } - - return generatedCode; - } - }); - } - - private boolean isCacheEnabled() { - return !RebindUtils.NO_CACHE; - } - - /** - * @return True iff there is a cached output for this generator. Useful for subclasses that must override {@link #isCacheValid()}. - */ - protected final boolean hasGenerationCache() { - final boolean hasCache = cacheMap.containsKey(getClass()); - if (log.isDebugEnabled()) { - log.debug("{} {} a generated cache.", getClass().getSimpleName(), (hasCache ? "has" : "does not have")); - } - return hasCache; - } - - protected final String getGeneratedCache() { - return cacheMap.get(getClass()); - } - - private final void setGeneratedCache(final String generated) { - cacheMap.put(getClass(), generated); - } - - /** - * @return True iff this generator does not need to be run again this refresh. - */ - protected boolean isCacheValid() { - return hasGenerationCache() && !(MetaClassFactory.hasAnyChanges() && hasRelevantChanges()); - } - - private boolean hasRelevantChanges() { - final String generatorName = this.getClass().getSimpleName(); - final Set relevantClasses = cacheRelevantClasses.get(this.getClass()); - if (relevantClasses == null) { - log.debug("No classes marked as relevant for {}. Assuming there are relevant changes.", generatorName); - return true; - } - - for (final MetaClass clazz : MetaClassFactory.getAllNewOrUpdatedClasses()) { - final boolean previouslyMarkedRelevant = relevantClasses.contains(clazz.getFullyQualifiedName()); - if (previouslyMarkedRelevant || isRelevantClass(clazz)) { - log.debug("New or updated class {} is {} cache relevant for {}.", clazz.getFullyQualifiedName(), - (previouslyMarkedRelevant ? "previously marked as" : "now marked as"), generatorName); - return true; - } else { - log.trace("New or updated class {} is not cache relevant for {}.", clazz.getFullyQualifiedName(), generatorName); - } - } - - for (final String deleted : MetaClassFactory.getAllDeletedClasses()) { - if (relevantClasses.contains(deleted)) { - log.debug("Deleted class {} was cache relevant for {}.", deleted, generatorName); - return true; - } else { - log.trace("Deleted class {} is not cache relevant for {}.", deleted, generatorName); - } - } - - return false; - } - - /** - * Checks if the provided class is relevant to this generator. This method is - * invoked to determine whether or not the introduction of the provided class - * should trigger a rerun of this generator. - * - * @param clazz - * a newly introduced clazz since the last refresh. - * - * @return true if newly introduced class is relevant to this generator, - * otherwise false. - */ - protected boolean isRelevantClass(final MetaClass clazz) { - return true; - } - - /** - * Called by {@link #generateAsync(TreeLogger, GeneratorContext)} to carry out the actual code - * generation. - * - * @param context - * the generator context to use. - * - * @return the generated code. - */ - protected abstract String generate(final TreeLogger logger, final GeneratorContext context); - - /** - * Starts all asynchronous generators if they haven't been started yet and waits for the - * completion of the generator responsible for the provided interface type. - * - * @param interfaceType - * the interface for which an implementation should be generated. - * @param context - * the generation context to use. - * @param logger - * the tree logger to use. - * @param packageName - * the package name of the generated class. - * @param className - * the name of the generated class. - * - * @return the fully qualified name of the generated class. - */ - protected String startAsyncGeneratorsAndWaitFor( - final Class interfaceType, - final GeneratorContext context, - final TreeLogger logger, - final String packageName, - final String className) { - - try { - final PrintWriter printWriter = context.tryCreate(logger, packageName, className); - if (printWriter != null) { - final Future future = AsyncGenerationJob.createBuilder() - .treeLogger(logger) - .generatorContext(context) - .interfaceType(interfaceType) - .runIfStarting(new Runnable() { - @Override - public void run() { - final long start = System.currentTimeMillis(); - MetaClassBridgeUtil.populateMetaClassFactoryFromTypeOracle(context, logger); - log.debug("MetaClassFactory populated in {}ms", System.currentTimeMillis() - start); - } - }) - .build() - // this causes all asynchronous code generators to run if this is the first one that executes. - .submit(); - - final String gen = future.get(); - printWriter.append(gen); - - RebindUtils.writeStringToJavaSourceFileInErraiCacheDir(packageName, className, gen); - - context.commit(logger, printWriter); - } - } - catch (final Throwable e) { - e.printStackTrace(); - logger.log(TreeLogger.ERROR, "Error generating " + className, e); - } - - return packageName + "." + className; - } - - /** - * Marks the provided class as cache relevant. This means that the provided - * class will be considered when checking for changes to determine whether or - * not the generator needs to rerun after a refresh. If no cache relevant - * classes are added any change to reloadable classes will cause the generator - * to rerun. - * - * @param clazz - * the class to consider when checking for changes. - */ - protected void addCacheRelevantClass(final MetaClass clazz) { - Set classes = cacheRelevantClasses.get(this.getClass()); - if (classes == null) { - classes = new HashSet(); - cacheRelevantClasses.put(this.getClass(), classes); - } - classes.add(clazz.getFullyQualifiedName()); - } - - /** - * Marks the provided classes as cache relevant. This means that the provided - * classes will be considered when checking for changes to determine whether - * or not the generator needs to rerun after a refresh. If no cache relevant - * classes are added any change to reloadable classes will cause the generator - * to rerun. - * - * @param classes - * the classes to consider when checking for changes. - */ - protected void addCacheRelevantClasses(final Collection classes) { - for (final MetaClass clazz : classes) { - addCacheRelevantClass(clazz); - } - } - - private void clearCacheRelevantClasses() { - cacheRelevantClasses.remove(this.getClass()); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-config/src/main/java/org/jboss/errai/config/rebind/AsyncCodeGenerator.java b/packages/serverless-workflow-diagram-editor/errai-config/src/main/java/org/jboss/errai/config/rebind/AsyncCodeGenerator.java deleted file mode 100644 index 1caca4f35fb..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-config/src/main/java/org/jboss/errai/config/rebind/AsyncCodeGenerator.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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 org.jboss.errai.config.rebind; - -import java.util.concurrent.Future; - -import com.google.gwt.core.ext.GeneratorContext; -import com.google.gwt.core.ext.TreeLogger; - -/** - * @author Mike Brock - */ -public interface AsyncCodeGenerator { - public Future generateAsync(TreeLogger logger, GeneratorContext context); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-config/src/main/java/org/jboss/errai/config/rebind/AsyncGenerationJob.java b/packages/serverless-workflow-diagram-editor/errai-config/src/main/java/org/jboss/errai/config/rebind/AsyncGenerationJob.java deleted file mode 100644 index b0292bb96f7..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-config/src/main/java/org/jboss/errai/config/rebind/AsyncGenerationJob.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * 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 org.jboss.errai.config.rebind; - -import java.util.concurrent.Future; - -import com.google.gwt.core.ext.GeneratorContext; -import com.google.gwt.core.ext.TreeLogger; -import org.jboss.errai.common.client.api.Assert; - -/** - * @author Mike Brock - */ -public class AsyncGenerationJob { - private final Runnable runIfStarting; - private final Runnable runIfStarted; - private final TreeLogger treeLogger; - private final GeneratorContext generatorContext; - private final Class interfaceType; - - private AsyncGenerationJob(Builder builder) { - this.runIfStarted = builder.runIfStarted; - this.runIfStarting = builder.runIfStarting; - this.treeLogger = Assert.notNull("treeLogger cannot be null", builder.treeLogger); - this.generatorContext = Assert.notNull("generatorContext cannot be null", builder.generatorContext); - this.interfaceType = Assert.notNull("interfaceType cannot be null", builder.interfaceType); - } - - public static Builder createBuilder() { - return new Builder(); - } - - public static class Builder { - private Runnable runIfStarting; - private Runnable runIfStarted; - private GeneratorContext generatorContext; - private TreeLogger treeLogger; - private Class interfaceType; - - public Builder runIfStarting(Runnable runnable) { - this.runIfStarting = runnable; - return this; - } - - public Builder runIfStarted(Runnable runnable) { - this.runIfStarted = runnable; - return this; - } - - public Builder generatorContext(GeneratorContext context) { - this.generatorContext = context; - return this; - } - - public Builder treeLogger(TreeLogger treeLogger) { - this.treeLogger = treeLogger; - return this; - } - - public Builder interfaceType(Class interfaceType) { - this.interfaceType = interfaceType; - return this; - } - - public AsyncGenerationJob build() { - return new AsyncGenerationJob(this); - } - } - - void notifyStarting() { - if (runIfStarting != null) { - runIfStarting.run(); - } - } - - void notifyStarted() { - if (runIfStarted != null) { - runIfStarted.run(); - } - } - - public TreeLogger getTreeLogger() { - return treeLogger; - } - - public GeneratorContext getGeneratorContext() { - return generatorContext; - } - - public Class getInterfaceType() { - return interfaceType; - } - - public Future submit() { - return AsyncGenerators.getFutureFor(this); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-config/src/main/java/org/jboss/errai/config/rebind/AsyncGenerators.java b/packages/serverless-workflow-diagram-editor/errai-config/src/main/java/org/jboss/errai/config/rebind/AsyncGenerators.java deleted file mode 100644 index 2ee5734e4a8..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-config/src/main/java/org/jboss/errai/config/rebind/AsyncGenerators.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * 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 org.jboss.errai.config.rebind; - -import java.util.Collections; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -import com.google.gwt.core.ext.GeneratorContext; -import com.google.gwt.core.ext.typeinfo.TypeOracleException; -import org.jboss.errai.common.metadata.ScannerSingleton; -import org.jboss.errai.common.rebind.CacheUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author Mike Brock - */ -public final class AsyncGenerators { - private static final Logger log = LoggerFactory.getLogger(AsyncGenerators.class); - - private AsyncGenerators() { - } - - private static final Object lock = new Object(); - private static volatile boolean started = false; - private static volatile GeneratorContext currentContext; - - private static final Map codeGenerators = new ConcurrentHashMap(); - private static final Map> activeFutures = new ConcurrentHashMap>(); - private static final Set startingNotifiedSet = Collections.newSetFromMap(new ConcurrentHashMap()); - private static final Set startedNotifiedSet = Collections.newSetFromMap(new ConcurrentHashMap()); - - static Future getFutureFor(final AsyncGenerationJob job) { - synchronized (lock) { - startAll(job); - - if (!codeGenerators.containsKey(job.getInterfaceType())) { - throw new RuntimeException("no generator found for interface: " + job.getInterfaceType().getName()); - } - - if (activeFutures.containsKey(job.getInterfaceType())) { - return activeFutures.get(job.getInterfaceType()); - } - else { - throw new RuntimeException("could not find future for interface: " + job.getInterfaceType().getName()); - } - } - } - - public static Future getFutureFor(final Class clazz) { - synchronized (lock) { - - if (!codeGenerators.containsKey(clazz)) { - throw new RuntimeException("no generator found for interface: " + clazz.getName()); - } - - if (activeFutures.containsKey(clazz)) { - return activeFutures.get(clazz); - } - else { - throw new RuntimeException("could not find future for interface: " + clazz.getName()); - } - } - } - - private static class FutureWrapper implements Future { - private final Class interfaceType; - private final Future delegate; - - private FutureWrapper(final Class interfaceType, final Future delegate) { - this.interfaceType = interfaceType; - this.delegate = delegate; - } - - @Override - public boolean cancel(final boolean mayInterruptIfRunning) { - return delegate.cancel(mayInterruptIfRunning); - } - - @Override - public boolean isCancelled() { - return delegate.isCancelled(); - } - - @Override - public boolean isDone() { - return delegate.isDone(); - } - - @Override - public String get() throws InterruptedException, ExecutionException { - final String val = delegate.get(); - activeFutures.remove(interfaceType); - return val; - } - - @Override - public String get(final long timeout, final TimeUnit unit) - throws InterruptedException, ExecutionException, TimeoutException { - final String val = delegate.get(timeout, unit); - activeFutures.remove(interfaceType); - return val; - } - } - - private static void startAll(final AsyncGenerationJob job) { - synchronized (lock) { - if (started && job.getGeneratorContext() != currentContext) { - codeGenerators.clear(); - activeFutures.clear(); - startedNotifiedSet.clear(); - startingNotifiedSet.clear(); - started = false; - } - - if (!started) { - started = true; - - EnvUtil.recordEnvironmentState(); - CacheUtil.clearAll(); - - currentContext = job.getGeneratorContext(); - - notifyStarting(job); - notifyStarted(job); - - final Set> typesAnnotatedWith = ScannerSingleton.getOrCreateInstance().getTypesAnnotatedWith(GenerateAsync.class); - for (final Class cls : typesAnnotatedWith) { - try { - final AsyncCodeGenerator asyncCodeGenerator - = cls.asSubclass(AsyncCodeGenerator.class).newInstance(); - - final GenerateAsync generateAsync = cls.getAnnotation(GenerateAsync.class); - - try { - job.getGeneratorContext().getTypeOracle().getType(generateAsync.value().getName()); - codeGenerators.put(generateAsync.value(), asyncCodeGenerator); - - log.info("discovered async generator " + cls.getName() + "; for type: " + generateAsync.value().getName()); - } - catch (TypeOracleException e) { - codeGenerators.remove(generateAsync.value()); - // e.printStackTrace(); - // ignore because not inherited in an active module. - } - } - catch (Throwable e) { - log.error("Generator failed to launch", e); - } - } - - for (final Map.Entry entry : codeGenerators.entrySet()) { - final Future value = entry.getValue().generateAsync(job.getTreeLogger(), job.getGeneratorContext()); - activeFutures.put(entry.getKey(), new FutureWrapper(entry.getKey(), value)); - } - } - else { - notifyStarted(job); - } - } - } - - private static void notifyStarting(AsyncGenerationJob job) { - if (startingNotifiedSet.contains(job)) { - return; - } - startingNotifiedSet.add(job); - job.notifyStarting(); - } - - private static void notifyStarted(AsyncGenerationJob job) { - if (startedNotifiedSet.contains(job)) { - return; - } - startedNotifiedSet.add(job); - job.notifyStarted(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-config/src/main/java/org/jboss/errai/config/rebind/EnvUtil.java b/packages/serverless-workflow-diagram-editor/errai-config/src/main/java/org/jboss/errai/config/rebind/EnvUtil.java deleted file mode 100644 index e29c6debf34..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-config/src/main/java/org/jboss/errai/config/rebind/EnvUtil.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * 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 org.jboss.errai.config.rebind; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.PropertyResourceBundle; -import java.util.ResourceBundle; -import java.util.concurrent.ConcurrentHashMap; - -import org.jboss.errai.common.metadata.ErraiAppPropertiesFiles; -import org.jboss.errai.common.rebind.CacheStore; -import org.jboss.errai.common.rebind.CacheUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author Mike Brock - */ -public abstract class EnvUtil { - public static class EnvironmentConfigCache implements CacheStore { - private volatile EnvironmentConfig environmentConfig; - private final Map permanentProperties = new ConcurrentHashMap<>(); - - public EnvironmentConfigCache() { - clear(); - } - - @Override - public synchronized void clear() { - environmentConfig = newEnvironmentConfig(); - environmentConfig.getFrameworkProperties().putAll(permanentProperties); - } - - public synchronized EnvironmentConfig get() { - return environmentConfig; - } - - public void addPermanentFrameworkProperty(final String name, final String value) { - permanentProperties.put(name, value); - environmentConfig.getFrameworkProperties().put(name, value); - } - } - - public static final String CONFIG_ERRAI_IOC_ENABLED_ALTERNATIVES = "errai.ioc.enabled.alternatives"; - public static final String CONFIG_ERRAI_BINDABLE_TYPES = "errai.ui.bindableTypes"; - public static final String CONFIG_ERRAI_NONBINDABLE_TYPES = "errai.ui.nonbindableTypes"; - - private static volatile Boolean _isJUnitTest; - - public static boolean isJUnitTest() { - if (_isJUnitTest != null) return _isJUnitTest; - - for (final StackTraceElement el : new Throwable().getStackTrace()) { - if (el.getClassName().startsWith("com.google.gwt.junit.client.") - || el.getClassName().startsWith("org.junit")) { - return _isJUnitTest = Boolean.TRUE; - } - } - return _isJUnitTest = Boolean.FALSE; - } - - private static volatile Boolean _isDevMode; - - public static boolean isDevMode() { - if (_isDevMode != null) return _isDevMode; - - for (final StackTraceElement el : new Throwable().getStackTrace()) { - if (el.getClassName().startsWith("com.google.gwt.dev.shell.OophmSessionHandler") || - el.getClassName().startsWith("com.google.gwt.dev.codeserver")) { - return _isDevMode = Boolean.TRUE; - } - } - return _isDevMode = Boolean.FALSE; - } - - private static volatile Boolean _isProdMode; - - public static boolean isProdMode() { - if (_isProdMode != null) return _isProdMode; - - return _isProdMode = Boolean.valueOf(!isDevMode() && !isJUnitTest()); - } - - public static void recordEnvironmentState() { - isJUnitTest(); - isDevMode(); - isProdMode(); - } - - private static Logger log = LoggerFactory.getLogger(EnvUtil.class); - - private static EnvironmentConfig newEnvironmentConfig() { - final Map frameworkProps = new HashMap<>(); - processErraiAppPropertiesFiles(frameworkProps); - return new EnvironmentConfig(frameworkProps); - } - - private static void processErraiAppPropertiesFiles(final Map frameworkProps) { - for (final URL url : getErraiAppPropertiesFilesUrls()) { - InputStream inputStream = null; - try { - log.debug("checking " + url.getFile() + " for configured types ..."); - inputStream = url.openStream(); - - final ResourceBundle props = new PropertyResourceBundle(inputStream); - processErraiAppPropertiesBundle(frameworkProps, props); - } catch (final IOException e) { - throw new RuntimeException("error reading ErraiApp.properties", e); - } - finally { - if (inputStream != null) { - try { - inputStream.close(); - } - catch (final IOException e) { - // - } - } - } - } - } - - private static void processErraiAppPropertiesBundle(final Map frameworkProps, final ResourceBundle props) { - for (final String key : props.keySet()) { - final String value = props.getString(key); - updateFrameworkProperties(frameworkProps, key, value); - } - } - - private static void updateFrameworkProperties(final Map frameworkProps, final String key, final String value) { - if (frameworkProps.containsKey(key)) { - if (isListValuedProperty(key)) { - // TODO should validate that different values don't conflict - final String oldValue = frameworkProps.get(key); - final String newValue = oldValue + " " + value; - log.debug("Merging property {} = {}", key, newValue); - frameworkProps.put(key, newValue); - } else { - log.warn("The property {} has been set multiple times.", key); - frameworkProps.put(key, value); - } - } else { - frameworkProps.put(key, value); - } - } - - private static boolean isListValuedProperty(final String key) { - return key.equals(CONFIG_ERRAI_IOC_ENABLED_ALTERNATIVES) - || key.equals(CONFIG_ERRAI_BINDABLE_TYPES) - || key.equals(CONFIG_ERRAI_NONBINDABLE_TYPES); - } - - public static Collection getErraiAppPropertiesFilesUrls() { - final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); - final ClassLoader envUtilClassLoader = EnvUtil.class.getClassLoader(); - - return ErraiAppPropertiesFiles.getUrls(contextClassLoader, envUtilClassLoader); - } - - /** - * @return an instance of {@link EnvironmentConfig}. Do NOT retain a reference to this value. Call every time - * you need additional configuration information. - */ - public static EnvironmentConfig getEnvironmentConfig() { - return CacheUtil.getCache(EnvironmentConfigCache.class).get(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-config/src/main/java/org/jboss/errai/config/rebind/EnvironmentConfig.java b/packages/serverless-workflow-diagram-editor/errai-config/src/main/java/org/jboss/errai/config/rebind/EnvironmentConfig.java deleted file mode 100644 index 93b882ebf82..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-config/src/main/java/org/jboss/errai/config/rebind/EnvironmentConfig.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 org.jboss.errai.config.rebind; - -import java.util.HashMap; -import java.util.Map; - -/** - * @author Mike Brock - */ -public class EnvironmentConfig { - private final Map frameworkProperties; - - EnvironmentConfig(final Map frameworkProperties) { - this.frameworkProperties = new HashMap(frameworkProperties); - } - - public Map getFrameworkProperties() { - return frameworkProperties; - } - - public String getFrameworkOrSystemProperty(String property) { - final String value = frameworkProperties.get(property); - if (value == null) { - return System.getProperty(property); - } - else { - return value; - } - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-config/src/main/java/org/jboss/errai/config/rebind/GenerateAsync.java b/packages/serverless-workflow-diagram-editor/errai-config/src/main/java/org/jboss/errai/config/rebind/GenerateAsync.java deleted file mode 100644 index 1a8829b2977..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-config/src/main/java/org/jboss/errai/config/rebind/GenerateAsync.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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 org.jboss.errai.config.rebind; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * @author Mike Brock - */ -@Retention(RetentionPolicy.RUNTIME) -public @interface GenerateAsync { - Class value(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-config/src/main/java/org/jboss/errai/config/rebind/MetaClassBridgeUtil.java b/packages/serverless-workflow-diagram-editor/errai-config/src/main/java/org/jboss/errai/config/rebind/MetaClassBridgeUtil.java deleted file mode 100644 index 88a377511f0..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-config/src/main/java/org/jboss/errai/config/rebind/MetaClassBridgeUtil.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * 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 org.jboss.errai.config.rebind; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import com.google.gwt.core.ext.GeneratorContext; -import com.google.gwt.core.ext.TreeLogger; -import com.google.gwt.core.ext.typeinfo.JClassType; -import com.google.gwt.core.ext.typeinfo.TypeOracle; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassCache; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.meta.impl.gwt.GWTClass; -import org.jboss.errai.codegen.meta.impl.java.JavaReflectionClass; -import org.jboss.errai.common.metadata.RebindUtils; -import org.jboss.errai.common.rebind.CacheStore; -import org.jboss.errai.common.rebind.CacheUtil; - -/** - * @author Mike Brock - */ -public abstract class MetaClassBridgeUtil { - private MetaClassBridgeUtil() {} - - /** - * Erases the {@link org.jboss.errai.codegen.meta.MetaClassFactory} cache, then populates it with types - * discovered via GWT's TypeOracle. The reason for the initial flush of the - * MetaClassFactory is to support hot redeploy in Dev Mode. The reason for doing - * this operation at all is so that the overridden class definitions - * (super-source classes) are used in preference to the Java reflection based - * class definitions. - * - * @param context - * The GeneratorContext supplied by the GWT compiler. Not null. - * @param logger - * The TreeLogger supplied by the GWT compiler. Not null. - */ - public synchronized static void populateMetaClassFactoryFromTypeOracle(final GeneratorContext context, - final TreeLogger logger) { - - final GWTTypeOracleCacheStore tOCache = CacheUtil.getCache(GWTTypeOracleCacheStore.class); - - // if we're in production mode -- it means we're compiling, and we do not need to accommodate dynamically - // changing classes. Therefore, do a NOOP after the first successful call. - if (context.equals(tOCache.populatedFrom)) { - return; - } - - final TypeOracle typeOracle = context.getTypeOracle(); - final MetaClassCache cache = MetaClassFactory.getMetaClassCache(); - - if (typeOracle != null) { - final Map classesToPush = new HashMap(typeOracle.getTypes().length); - final Set translatable = new HashSet(RebindUtils.findTranslatablePackages(context)); - // Need to remove these or else we get issues from annotations and loading - // of emulated Object and Class instead of real ones. - translatable.remove("java.lang"); - translatable.remove("java.lang.annotation"); - final Set reloadable = RebindUtils.getReloadablePackageNames(context); - - for (final JClassType type : typeOracle.getTypes()) { - if (!translatable.contains(type.getPackage().getName())) { - continue; - } - - if (type.isAnnotation() != null || type.getQualifiedSourceName().equals("java.lang.annotation.Annotation")) { - - if (!MetaClassFactory.canLoadClass(type.getQualifiedBinaryName())) { - throw new RuntimeException("a new annotation has been introduced (" + type.getQualifiedSourceName() + "); " - + "you cannot currently introduce new annotations in devmode. Please restart."); - } - - final MetaClass clazz = JavaReflectionClass - .newUncachedInstance(MetaClassFactory.loadClass(type.getQualifiedBinaryName())); - - if (isReloadable(clazz, reloadable)) { - classesToPush.put(clazz.getFullyQualifiedName(), clazz); - } else if (!cache.isKnownType(clazz.getFullyQualifiedName())) { - cache.pushCache(clazz); - } - } - else { - logger.log(TreeLogger.Type.DEBUG, "Caching translatable type " + type.getQualifiedSourceName()); - final MetaClass clazz = GWTClass.newUncachedInstance(typeOracle, type); - - if (isReloadable(clazz, reloadable)) { - classesToPush.put(clazz.getFullyQualifiedName(), clazz); - } else if (!cache.isKnownType(clazz.getFullyQualifiedName())) { - cache.pushCache(clazz); - } - } - } - - cache.updateCache(classesToPush); - } - tOCache.populatedFrom = context; - - CacheUtil.getCache(EnvUtil.EnvironmentConfigCache.class).clear(); - } - - private static boolean isReloadable(final MetaClass clazz, final Set reloadablePacakges) { - for (final String packageName : reloadablePacakges) { - if (clazz.getPackageName().startsWith(packageName)) - return true; - } - - return false; - } - - public static class GWTTypeOracleCacheStore implements CacheStore { - volatile GeneratorContext populatedFrom; - - @Override - public void clear() { - populatedFrom = null; - } - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-config/src/main/java/org/jboss/errai/config/util/ClassScanner.java b/packages/serverless-workflow-diagram-editor/errai-config/src/main/java/org/jboss/errai/config/util/ClassScanner.java deleted file mode 100644 index da4c78539af..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-config/src/main/java/org/jboss/errai/config/util/ClassScanner.java +++ /dev/null @@ -1,435 +0,0 @@ -/* - * 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 org.jboss.errai.config.util; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.atomic.AtomicLong; -import java.util.regex.Pattern; - -import com.google.gwt.core.ext.GeneratorContext; -import org.jboss.errai.codegen.meta.MetaClass; -import org.jboss.errai.codegen.meta.MetaClassFactory; -import org.jboss.errai.codegen.meta.MetaField; -import org.jboss.errai.codegen.meta.MetaMethod; -import org.jboss.errai.codegen.meta.MetaParameter; -import org.jboss.errai.codegen.meta.impl.java.JavaReflectionField; -import org.jboss.errai.codegen.meta.impl.java.JavaReflectionMethod; -import org.jboss.errai.common.metadata.RebindUtils; -import org.jboss.errai.common.metadata.ScannerSingleton; -import org.jboss.errai.common.rebind.CacheStore; -import org.jboss.errai.common.rebind.CacheUtil; -import org.mvel2.util.NullType; - -/** - * @author Mike Brock - * @author Christian Sadilek - */ -public final class ClassScanner { - public static class CacheHolder implements CacheStore { - final Map> subtypesCache = new ConcurrentHashMap>(); - final Collection reloadableClasses = new CopyOnWriteArrayList(); - final Set reloadableClassNames = Collections.newSetFromMap(new ConcurrentHashMap()); - final Set reloadablePackages = Collections.newSetFromMap(new ConcurrentHashMap()); - - @Override - public void clear() { - subtypesCache.clear(); - reloadableClasses.clear(); - reloadableClassNames.clear(); - reloadablePackages.clear(); - } - } - final static CacheHolder cache = CacheUtil.getCache(CacheHolder.class); - - private static final ThreadLocal reflectionScanLocal = new ThreadLocal() { - @Override - protected Boolean initialValue() { - return Boolean.FALSE; - } - }; - - private static AtomicLong totalClassScanTime = new AtomicLong(0); - - private ClassScanner() { - } - - public static Collection getParametersAnnotatedWith(final Class annotation, - final Set packages, final GeneratorContext genCtx) { - - final Collection result = new HashSet(); - - if (genCtx != null) { - for (final MetaClass metaClass : getAllReloadableCachedClasses(genCtx)) { - for (final MetaMethod method : metaClass.getDeclaredMethods()) { - for (final MetaParameter parameter : method.getParameters()) { - if (parameter.isAnnotationPresent(annotation)) { - result.add(parameter); - } - } - } - } - try { - for (final Method m : ScannerSingleton.getOrCreateInstance().getMethodsWithAnyParamAnnotated(annotation)) { - Class clazz = m.getDeclaringClass(); - if (!isReloadable(clazz) && MetaClassFactory.isKnownType(clazz.getName())) { - MetaMethod mm = new JavaReflectionMethod(m); - for (final MetaParameter parameter : mm.getParameters()) { - if (parameter.isAnnotationPresent(annotation)) { - result.add(parameter); - } - } - } - } - } catch (Exception ignored) { - } - } - else { - for (final MetaClass metaClass : MetaClassFactory.getAllCachedClasses()) { - for (final MetaMethod method : metaClass.getDeclaredMethods()) { - for (final MetaParameter parameter : method.getParameters()) { - if (parameter.isAnnotationPresent(annotation)) { - result.add(parameter); - } - } - } - } - } - - filterResultsParameter(result, packages, null); - return Collections.unmodifiableCollection(result); - } - - public static Collection getParametersAnnotatedWith(final Class annotation, - final GeneratorContext genCtx) { - return getParametersAnnotatedWith(annotation, null, genCtx); - } - - public static Collection getTypesAnnotatedWith(final Class annotation, - final Set packages, final String excludeRegEx, final GeneratorContext genCtx, boolean reflections) { - - final Collection result = new HashSet(); - - if (genCtx != null) { - for (final MetaClass metaClass : getAllReloadableCachedClasses(genCtx)) { - if (metaClass.isAnnotationPresent(annotation)) { - result.add(metaClass); - } - } - try { - for (final Class cls : ScannerSingleton.getOrCreateInstance().getTypesAnnotatedWith(annotation)) { - if (!isReloadable(cls) && MetaClassFactory.isKnownType(cls.getName())) { - result.add(MetaClassFactory.get(cls)); - } - } - } catch (Exception ignored) { - } - } - else { - for (final MetaClass metaClass : MetaClassFactory.getAllCachedClasses()) { - if (metaClass.isAnnotationPresent(annotation)) { - result.add(metaClass); - } - } - - try { - if (reflections || reflectionScanLocal.get()) { - for (final Class cls : ScannerSingleton.getOrCreateInstance().getTypesAnnotatedWith(annotation)) { - final MetaClass e = MetaClassFactory.get(cls); - result.add(e); - } - } - } catch (Exception ignored) { - } - } - filterResultsClass(result, packages, excludeRegEx); - return Collections.unmodifiableCollection(result); - } - - public static Collection getTypesAnnotatedWith(final Class annotation) { - return getTypesAnnotatedWith(annotation, null, null, null, false); - } - - public static Collection getTypesAnnotatedWith(final Class annotation, - boolean reflections) { - return getTypesAnnotatedWith(annotation, null, null, null, reflections); - } - - public static Collection getTypesAnnotatedWith(final Class annotation, - final GeneratorContext genCtx) { - return getTypesAnnotatedWith(annotation, null, null, genCtx, true); - } - - public static Collection getTypesAnnotatedWith(final Class annotation, - final Set packages, final GeneratorContext genCtx) { - return getTypesAnnotatedWith(annotation, packages, null, genCtx, true); - } - - public static Collection getTypesAnnotatedWithExcluding(final Class annotation, - final String excludeRegex, final GeneratorContext genCtx) { - return getTypesAnnotatedWith(annotation, null, excludeRegex, genCtx, true); - } - - public static Collection getMethodsAnnotatedWith(final Class annotation, - final Set packages, final GeneratorContext genCtx) { - final Collection result = new HashSet(50); - - if (genCtx != null) { - for (final MetaClass metaClass : getAllReloadableCachedClasses(genCtx)) { - for (final MetaMethod metaMethod : metaClass.getDeclaredMethods()) { - if (metaMethod.isAnnotationPresent(annotation)) { - result.add(metaMethod); - } - } - } - try { - for (final Method m : ScannerSingleton.getOrCreateInstance().getMethodsAnnotatedWith(annotation)) { - Class clazz = m.getDeclaringClass(); - if (!isReloadable(clazz) && MetaClassFactory.isKnownType(clazz.getName())) { - final MetaClass metaClass = MetaClassFactory.get(clazz); - result.add(new JavaReflectionMethod(metaClass, m)); - } - } - } catch (Exception ignored) { - } - } - else { - for (final MetaClass metaClass : MetaClassFactory.getAllCachedClasses()) { - for (final MetaMethod metaMethod : metaClass.getDeclaredMethods()) { - if (metaMethod.isAnnotationPresent(annotation)) { - result.add(metaMethod); - } - } - } - } - - filterResultsMethod(result, packages, null); - return Collections.unmodifiableCollection(result); - } - - public static Collection getFieldsAnnotatedWith(final Class annotation, - final Set packages, final GeneratorContext genCtx) { - final Collection result = new HashSet(50); - - if (genCtx != null) { - for (final MetaClass metaClass : getAllReloadableCachedClasses(genCtx)) { - for (final MetaField metaField : metaClass.getDeclaredFields()) { - if (metaField.isAnnotationPresent(annotation)) { - result.add(metaField); - } - } - } - try { - for (final Field f : ScannerSingleton.getOrCreateInstance().getFieldsAnnotatedWith(annotation)) { - Class clazz = f.getDeclaringClass(); - if (!isReloadable(clazz) && MetaClassFactory.isKnownType(clazz.getName())) { - result.add(new JavaReflectionField(f)); - } - } - } catch (Exception ignored) { - } - } - else { - for (final MetaClass metaClass : MetaClassFactory.getAllCachedClasses()) { - for (final MetaField metaField : metaClass.getDeclaredFields()) { - if (metaField.isAnnotationPresent(annotation)) { - result.add(metaField); - } - } - } - } - - filterResultsField(result, packages, null); - return Collections.unmodifiableCollection(result); - } - - public static Collection getSubTypesOf(final MetaClass metaClass, final GeneratorContext genCtx) { - final MetaClass root = metaClass.getErased(); - - if (cache.subtypesCache.containsKey(root)) { - return cache.subtypesCache.get(root); - } - - final Set result = Collections.newSetFromMap(new ConcurrentHashMap()); - - if (!Boolean.getBoolean("org.jboss.errai.skip.reloadable.subtypes")) { - for (final MetaClass mc : getAllReloadableCachedClasses(genCtx)) { - if (!NullType.class.getName().equals(mc.getFullyQualifiedName()) - && !root.getFullyQualifiedName().equals(mc.getFullyQualifiedName()) && root.isAssignableFrom(mc)) { - result.add(mc.getErased()); - } - } - } - - final Class cls = root.asClass(); - if (cls != null && !cls.equals(NullType.class)) { - for (final Class c : ScannerSingleton.getOrCreateInstance().getSubTypesOf(cls)) { - if (!c.isAnonymousClass() && !c.isSynthetic()) { - result.add(MetaClassFactory.get(c)); - } - } - } - - cache.subtypesCache.put(root, result); - return result; - } - - private static Collection getAllReloadableCachedClasses(final GeneratorContext context) { - if (cache.reloadablePackages.isEmpty()) { - cache.reloadablePackages.addAll(RebindUtils.getReloadablePackageNames(context)); - } - if (!cache.reloadableClasses.isEmpty()) { - return cache.reloadableClasses; - } - - final Collection classes = new ArrayList(); - final Collection classNames = new ArrayList(); - - for (MetaClass clazz : MetaClassFactory.getAllCachedClasses()) { - final String fqcn = clazz.getFullyQualifiedName(); - final String pkg = clazz.getPackageName(); - - if (pkg !=null && cache.reloadablePackages.contains(pkg)) { - classes.add(clazz); - classNames.add(fqcn); - } - else { - for (String reloadablePackage : cache.reloadablePackages) { - if (fqcn.startsWith(reloadablePackage)) { - classes.add(clazz); - classNames.add(fqcn); - if (pkg != null) { - cache.reloadablePackages.add(pkg); - } - break; - } - } - } - } - cache.reloadableClasses.addAll(classes); - cache.reloadableClassNames.addAll(classNames); - return classes; - } - - private static boolean isReloadable(Class clazz) { - return cache.reloadableClassNames.contains(clazz.getName()); - } - - private static void filterResultsClass(final Collection result, final Set packages, - final String excludeRegEx) { - - final Pattern excludePattern; - if (excludeRegEx != null) { - excludePattern = Pattern.compile(excludeRegEx); - } - else { - excludePattern = null; - } - - final Iterator filterIterator = result.iterator(); - while (filterIterator.hasNext()) { - _removeIfNotMatches(filterIterator, filterIterator.next(), packages, excludePattern); - } - } - - private static void filterResultsMethod(final Collection result, final Set packages, - final String excludeRegEx) { - - final Pattern excludePattern; - if (excludeRegEx != null) { - excludePattern = Pattern.compile(excludeRegEx); - } - else { - excludePattern = null; - } - - final Iterator filterIterator = result.iterator(); - while (filterIterator.hasNext()) { - _removeIfNotMatches(filterIterator, filterIterator.next().getDeclaringClass(), packages, excludePattern); - } - } - - private static void filterResultsField(final Collection result, final Set packages, - final String excludeRegEx) { - - final Pattern excludePattern; - if (excludeRegEx != null) { - excludePattern = Pattern.compile(excludeRegEx); - } - else { - excludePattern = null; - } - - final Iterator filterIterator = result.iterator(); - while (filterIterator.hasNext()) { - _removeIfNotMatches(filterIterator, filterIterator.next().getDeclaringClass(), packages, excludePattern); - } - } - - private static void filterResultsParameter(final Collection result, final Set packages, - final String excludeRegEx) { - - final Pattern excludePattern; - if (excludeRegEx != null) { - excludePattern = Pattern.compile(excludeRegEx); - } - else { - excludePattern = null; - } - - final Iterator filterIterator = result.iterator(); - while (filterIterator.hasNext()) { - _removeIfNotMatches(filterIterator, filterIterator.next().getDeclaringMember().getDeclaringClass(), packages, - excludePattern); - } - } - - private static void _removeIfNotMatches(final Iterator iterator, final MetaClass type, final Set packages, - final Pattern excludePattern) { - - if (packages == null || packages.contains(type.getPackageName())) { - if (excludePattern != null && excludePattern.matcher(type.getFullyQualifiedName()).matches()) { - iterator.remove(); - } - } - else { - iterator.remove(); - } - } - - public static void setReflectionsScanning(final boolean bool) { - reflectionScanLocal.set(bool); - } - - public static AtomicLong getTotalClassScanTime() { - return totalClassScanTime; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-config/src/main/java/org/jboss/errai/config/util/ThreadUtil.java b/packages/serverless-workflow-diagram-editor/errai-config/src/main/java/org/jboss/errai/config/util/ThreadUtil.java deleted file mode 100644 index 32fb838bf79..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-config/src/main/java/org/jboss/errai/config/util/ThreadUtil.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * 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 org.jboss.errai.config.util; - -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -/** - * @author Mike Brock - */ -public class ThreadUtil { - private static final ExecutorService executorService - = Executors.newFixedThreadPool(Math.max(2, Runtime.getRuntime().availableProcessors())); - - public static void execute(final Runnable runnable) { - executorService.execute(runnable); - } - - public static Future submit(final Callable callable) { - return executorService.submit(callable); - } - - public static Future submit(final Runnable runnable) { - return executorService.submit(runnable); - } - - public static void stopExecutor() { - executorService.shutdown(); - } - - public static class SynchronousCallableFuture implements Future { - private final Callable runnable; - - public SynchronousCallableFuture(final Callable runnable) { - this.runnable = runnable; - } - - @Override - public boolean cancel(final boolean mayInterruptIfRunning) { - return false; - } - - @Override - public boolean isCancelled() { - return false; - } - - @Override - public boolean isDone() { - return false; - } - - @Override - public V get() throws InterruptedException, ExecutionException { - try { - return runnable.call(); - } - catch (Throwable t) { - throw new RuntimeException(t); - } - } - - @Override - public V get(final long timeout, final TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { - try { - return runnable.call(); - } - catch (Throwable t) { - throw new RuntimeException(t); - } - } - - - } - - public static class SynchronousRunnableeFuture implements Future { - private final Runnable runnable; - - public SynchronousRunnableeFuture(final Runnable runnable) { - this.runnable = runnable; - } - - @Override - public boolean cancel(final boolean mayInterruptIfRunning) { - return false; - } - - @Override - public boolean isCancelled() { - return false; - } - - @Override - public boolean isDone() { - return false; - } - - @Override - public V get() throws InterruptedException, ExecutionException { - try { - System.out.println("**RUN SYNC**"); - runnable.run(); - return null; - } - catch (Throwable t) { - throw new RuntimeException(t); - } - } - - @Override - public V get(final long timeout, final TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { - try { - runnable.run(); - return null; - } - catch (Throwable t) { - throw new RuntimeException(t); - } - } - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/pom.xml b/packages/serverless-workflow-diagram-editor/errai-ioc/pom.xml deleted file mode 100644 index 40d9af9e804..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/pom.xml +++ /dev/null @@ -1,227 +0,0 @@ - - - 4.0.0 - Errai::IOC - errai-ioc - jar - - - - org.kie.kogito.stunner.serverless.editor - stunner-editors-parent - ${revision} - ../pom.xml - - - - - - src/main/java - - - src/main/resources - - - - - src/test/java - - - src/test/resources - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - test-jar - - - - - - - - - - - - org.kie.kogito.stunner.serverless.editor - errai-config - - - - org.kie.kogito.stunner.serverless.editor - errai-codegen - - - - org.kie.kogito.stunner.serverless.editor - errai-codegen-gwt - - - - com.google.inject - guice - - - - com.google.guava - guava-gwt - compile - - - - javax.inject - javax.inject - - - - org.jboss.spec.javax.annotation - jboss-annotations-api_1.2_spec - - - - org.kie.kogito.stunner.serverless.editor - errai-javax-enterprise - provided - - - - javax.enterprise - cdi-api - - - javax.el - javax.el-api - - - javax.interceptor - javax.interceptor-api - - - - - - - org.gwtproject - gwt-user - - provided - - - - org.gwtproject - gwt-dev - - provided - - - org.eclipse.jetty - jetty-annotations - - - - - - junit - junit - - - provided - - - - org.mockito - mockito-core - test - - - - com.google.elemental2 - elemental2-dom - - - - - - integration-test - - - - org.kie.kogito.stunner.serverless.editor - errai-codegen - - - org.eclipse.jdt - ecj - - - - - - - - - maven-failsafe-plugin - - - - - 1 - false - -Xmx1500m -Dgwt.gen=/tmp/gwt_test_gen_out/ -Derrai.codegen.details=true -Dgwt.args='-testBeginTimeout 5 -generateJsInteropExports ${gwtArgs}' -Xdebug - false - - - java.io.tmpdir - ${project.build.directory} - - - log4j.output.dir - ${project.build.directory} - - - errai.ioc.jsinterop.support - true - - - - - **/IOCTests.java - **/org/jboss/errai/ioc/async/test/**/*.java - **/unit/**/*.java - **/*UnitTest.java - - - - - maven-surefire-plugin - - - - - - **/unit/**/*Test.java - **/*UnitTest.java - - - - - - - - - diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/Container.gwt.xml b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/Container.gwt.xml deleted file mode 100644 index 5aad1375881..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/Container.gwt.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/AnnotationComparator.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/AnnotationComparator.java deleted file mode 100644 index 0e1b94879a8..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/AnnotationComparator.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client; - -import java.lang.annotation.Annotation; - -/** - * A simple comparator interface used by the {@link QualifierEqualityFactory} generator to create comparators for - * testing the equality of qualifiers at runtime. - *

- * NOTE: This interface is only for tested the attribute-equality of like-typed annotations. For instance, you can - * only compare an annotation of type Foo with another annotation of type Foo. You cannot - * compare the equality of Foo with Bar. Attempting to do so will simply result in a - * ClassCastException. - * - * @author Mike Brock - */ -public interface AnnotationComparator { - /** - * Tests the equality of two qualifiers. Does not accept null values. - * - * @param a1 an annotation to be compared. cannot be null. - * @param a2 an annotation to be compared. cannot be null. - * @return true if the annotations match. - */ - public boolean isEqual(T a1, T a2); - - /** - * Creates a consistent hashCode based on the attribute values of the annotation. - * - * @param a1 the annotation to have a hashCode generated for. cannot be null. - * @return a consistent hash code. - */ - public int hashCodeOf(T a1); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/Bootstrapper.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/Bootstrapper.java deleted file mode 100644 index d924b04919a..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/Bootstrapper.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client; - -import org.jboss.errai.ioc.client.container.ContextManager; - -public interface Bootstrapper { - ContextManager bootstrapContainer(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/Container.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/Container.java deleted file mode 100644 index 99f706f8f35..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/Container.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client; - -import java.util.ArrayList; -import java.util.List; - -import com.google.gwt.core.client.EntryPoint; -import com.google.gwt.core.client.GWT; -import com.google.gwt.core.client.GWT.UncaughtExceptionHandler; -import org.jboss.errai.ioc.client.container.BeanManagerSetup; -import org.jboss.errai.ioc.client.container.ContextManager; -import org.jboss.errai.ioc.client.container.ErraiUncaughtExceptionHandler; -import org.jboss.errai.ioc.client.container.IOC; -import org.jboss.errai.ioc.client.container.IOCEnvironment; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class Container implements EntryPoint { - - private static final Logger logger = LoggerFactory.getLogger(Container.class); - - @Override - public void onModuleLoad() { - bootstrapContainer(); - } - - private void setUncaughtExceptionHandler() { - final UncaughtExceptionHandler replacedHandler = GWT.getUncaughtExceptionHandler(); - GWT.setUncaughtExceptionHandler(new ErraiUncaughtExceptionHandler(replacedHandler)); - } - - public void bootstrapContainer() { - setUncaughtExceptionHandler(); - logger.info("Starting to bootstrap IOC container..."); - final long bootstrapStart = System.currentTimeMillis(); - try { - init = false; - - logger.debug("Initializing {}...", QualifierEqualityFactory.class.getSimpleName()); - long start = System.currentTimeMillis(); - QualifierUtil.initFromFactoryProvider(() -> GWT.create(QualifierEqualityFactory.class)); - logger.debug("{} initialized in {}ms", QualifierEqualityFactory.class.getSimpleName(), System.currentTimeMillis() - start); - - final BeanManagerSetup beanManager; - if (GWT.create(IOCEnvironment.class).isAsync()) { - logger.info("Bean manager initialized in async mode."); - beanManager = (BeanManagerSetup) IOC.getAsyncBeanManager(); - } else { - beanManager = (BeanManagerSetup) IOC.getBeanManager(); - } - - logger.debug("Creating new {} instance...", Bootstrapper.class.getSimpleName()); - start = System.currentTimeMillis(); - final Bootstrapper bootstrapper = GWT.create(Bootstrapper.class); - logger.debug("Created {} instance in {}ms", Bootstrapper.class.getSimpleName(), System.currentTimeMillis() - start); - - logger.debug("Creating new {} instance...", ContextManager.class.getSimpleName()); - start = System.currentTimeMillis(); - final ContextManager contextManager = bootstrapper.bootstrapContainer(); - logger.debug("Created {} instance in {}ms", ContextManager.class.getSimpleName(), System.currentTimeMillis() - start); - - logger.debug("Initializing bean manager..."); - start = System.currentTimeMillis(); - beanManager.setContextManager(contextManager); - logger.debug("Bean manager initialized in {}ms", System.currentTimeMillis() - start); - - logger.debug("Running post initialization runnables..."); - start = System.currentTimeMillis(); - init = true; - for (final Runnable run : afterInit) { - run.run(); - } - afterInit.clear(); - logger.debug("All post initialization runnables finished in {}ms", System.currentTimeMillis() - start); - - logger.info("IOC bootstrapper successfully initialized in {}ms", System.currentTimeMillis() - bootstrapStart); - } - catch (final RuntimeException ex) { - logger.error("Critical error in IOC container bootstrap.", ex); - - throw ex; - } - } - - private static final List afterInit = new ArrayList<>(); - private static boolean init = false; - - /** - * Runs the specified {@link Runnable} only after the bean manager has fully initialized. It is generally not - * necessary to use this method from within beans themselves. But if you are generated out-of-container calls - * into the bean manager (such as for testing), it may be necessary to use this method to ensure that the beans - * you wish to lookup have been loaded. - *

- * Use of this method is really only necessary when using the bean manager in asynchronous mode as wiring of the - * container synchronously does not yield during bootstrapping operations. - *

- * If the bean manager is already initialized when you call this method, the Runnable is invoked immediately. - * - * @param runnable - * the {@link Runnable} to execute after bean manager initialization. - */ - public static void runAfterInit(final Runnable runnable) { - if (init) { - runnable.run(); - } else { - afterInit.add(runnable); - } - } - - /** - * Short-alias method for {@link #runAfterInit(Runnable)}. - * - * @param runnable - */ - public static void $(final Runnable runnable) { - runAfterInit(runnable); - } - - public static void reset() { - init = false; - afterInit.clear(); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/IOCUtil.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/IOCUtil.java deleted file mode 100644 index c361c581f26..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/IOCUtil.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client; - -import java.lang.annotation.Annotation; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -import com.google.gwt.core.client.GWT; -import org.jboss.errai.ioc.client.container.IOC; -import org.jboss.errai.ioc.client.container.IOCEnvironment; -import org.jboss.errai.ioc.client.container.IOCResolutionException; -import org.jboss.errai.ioc.client.container.SyncBeanDef; - -/** - * - * @author Max Barkley - */ -public abstract class IOCUtil { - - private IOCUtil() {}; - - private static final IOCEnvironment IOC_ENVIRONMENT = GWT. create(IOCEnvironment.class); - - public static T getInstance(final Class type, final Annotation... qualifiers) { - return getSyncBean(type, qualifiers).getInstance(); - } - - public static SyncBeanDef getSyncBean(final Class type, final Annotation... qualifiers) { - try { - return IOC.getBeanManager().lookupBean(type, qualifiers); - } catch (final IOCResolutionException ex) { - if (IOC_ENVIRONMENT.isAsync() && isUnsatisfied(type, qualifiers)) { - throw new RuntimeException("No bean satisfied " + prettyQualifiersAndType(type, qualifiers) - + ". Hint: Types loaded via Instance should not be @LoadAsync.", ex); - } - else { - throw ex; - } - } - } - - public static void destroy(final Object instance) { - IOC.getBeanManager().destroyBean(instance); - } - - public static boolean isUnsatisfied(final Class type, final Annotation... qualifiers) { - return IOC.getBeanManager().lookupBeans(type, qualifiers).isEmpty(); - } - - public static boolean isAmbiguous(final Class type, final Annotation... qualifiers) { - return IOC.getBeanManager().lookupBeans(type, qualifiers).size() > 1; - } - - public static Annotation[] joinQualifiers(final Annotation[] a1, final Annotation[] a2) { - final Set annos = new HashSet<>(); - annos.addAll(Arrays.asList(a1)); - annos.addAll(Arrays.asList(a2)); - - return annos.toArray(new Annotation[annos.size()]); - } - - private static String prettyQualifiersAndType(final Class type, final Annotation... qualifiers) { - final StringBuilder builder = new StringBuilder(); - for (final Annotation qual : qualifiers) { - builder.append('@').append(qual.annotationType().getSimpleName()).append(' '); - } - builder.append(type.getSimpleName()); - - return builder.toString(); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/JsArray.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/JsArray.java deleted file mode 100644 index 3fc64b0a127..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/JsArray.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client; - -import java.util.Iterator; -import java.util.NoSuchElementException; - -import jsinterop.annotations.JsIgnore; -import jsinterop.annotations.JsType; - -/** - * - * @author Max Barkley - */ -@JsType -public class JsArray { - - @JsIgnore - public static Iterable iterable(final JsArray array) { - return () -> { - return new Iterator() { - private int i = 0; - @Override - public boolean hasNext() { - return i < array.length(); - } - - @Override - public T next() { - if (hasNext()) { - return array.get(i++); - } - else { - throw new NoSuchElementException(); - } - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - }; - }; - } - - private final T[] wrapped; - - @JsIgnore - public JsArray(final T[] wrapped) { - this.wrapped = wrapped; - } - - public int length() { - return wrapped.length; - } - - public T get(int index) { - return wrapped[index]; - } - - public void set(int index, T value) { - wrapped[index] = value; - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/QualifierEqualityFactory.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/QualifierEqualityFactory.java deleted file mode 100644 index f8afe05a455..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/QualifierEqualityFactory.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client; - -import java.lang.annotation.Annotation; - -/** - * An interface which is implemented by the code generator to allow equality tests on annotations which consider - * their attributes as part of the equality check. - * - * @author Mike Brock - */ -public interface QualifierEqualityFactory { - public boolean isEqual(Annotation a1, Annotation a2); - - public int hashCodeOf(Annotation a1); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/QualifierEqualityFactoryProvider.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/QualifierEqualityFactoryProvider.java deleted file mode 100644 index 6609e9b4084..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/QualifierEqualityFactoryProvider.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client; - -/** - * @author Mike Brock - */ -public interface QualifierEqualityFactoryProvider { - public QualifierEqualityFactory provide(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/QualifierUtil.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/QualifierUtil.java deleted file mode 100644 index 8325636738f..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/QualifierUtil.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client; - -import java.lang.annotation.Annotation; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -import javax.enterprise.inject.Any; -import javax.enterprise.inject.Default; -import javax.inject.Named; - -/** - * A utility class for testing the equality of qualifiers at runtime. - * - * @author Mike Brock - */ -public class QualifierUtil { - public static final Annotation DEFAULT_ANNOTATION = new Default() { - @Override - public Class annotationType() { - return Default.class; - } - @Override - public String toString() { - return "@Default"; - }; - }; - - public static final Annotation ANY_ANNOTATION = new Any() { - @Override - public Class annotationType() { - return Any.class; - } - @Override - public String toString() { - return "@Any"; - }; - }; - - public static final Annotation[] DEFAULT_QUALIFIERS = new Annotation[]{ - DEFAULT_ANNOTATION, - ANY_ANNOTATION - }; - - @SuppressWarnings("serial") - private static final Map DEFAULT_MATCHING_MAP = new HashMap() { - { - for (final Annotation a : DEFAULT_QUALIFIERS) { - put(a.annotationType().getName(), a); - } - } - }; - - private static QualifierEqualityFactoryProvider factoryProvider; - private static QualifierEqualityFactory factory; - - public static void init() { - if (factory == null) - factory = factoryProvider.provide(); - } - - public static boolean isEqual(final Annotation a1, final Annotation a2) { - return factory.isEqual(a1, a2); - } - - public static boolean isSameType(final Annotation a1, final Annotation a2) { - return !(a1 == null || a2 == null) && a1.annotationType().equals(a2.annotationType()); - } - - public static int hashCodeOf(final Annotation a1) { - - return factory.hashCodeOf(a1); - } - - /** - * @param allOf - * A collection of qualifiers that must be satisfied. - * @param in - * A collection of qualifiers for potentially satisfying - * {@code allOf}. If this collection is empty, then it represents the - * universal qualifier that satisfies all other qualifiers. This is - * unambiguous since it is otherwise impossible to have no qualifiers - * (everything has {@link Any}). - * @return If {@code in} is non-empty then this returns true iff every - * annotation in {@code allOff} contains an equal annotation in - * {@code in}. If {@code in} is empty, then this returns true. - */ - public static boolean matches(final Collection allOf, final Collection in) { - if (in.isEmpty()) { - return true; - } else { - return contains(allOf, in); - } - } - - public static boolean contains(final Collection allOf, final Collection in) { - if (allOf.isEmpty()) return true; - - final Map allOfMap = new HashMap<>(); - final Map inMap = new HashMap<>(); - - for (final Annotation a : in) { - inMap.put(a.annotationType().getName(), a); - } - - for (final Annotation a : allOf) { - allOfMap.put(a.annotationType().getName(), a); - } - - if (!inMap.keySet().containsAll(allOfMap.keySet())) { - return false; - } - - if (factory != null) { - for (final Map.Entry entry : allOfMap.entrySet()) { - if (!factory.isEqual(entry.getValue(), inMap.get(entry.getKey()))) { - return false; - } - } - } - return true; - } - - public static boolean isDefaultAnnotations(final Annotation[] annotations) { - return annotations == null || isDefaultAnnotations(Arrays.asList(annotations)); - } - - - public static boolean isDefaultAnnotations(final Collection annotations) { - return annotations == null || (annotations.size() == 2 && contains(DEFAULT_MATCHING_MAP.values(), annotations)); - } - - public static void initFromFactoryProvider(final QualifierEqualityFactoryProvider provider) { - factoryProvider = provider; - factory = null; - init(); - } - - public static int hashValueFor(final int i) { - return i; - } - - public static int hashValueFor(final boolean b) { - return b ? 1 : 0; - } - - public static int hashValueFor(final long l) { - return (int) l; - } - - public static int hashValueFor(final float f) { - return (int) f * 1000; - } - - public static int hashValueFor(final double d) { - return (int) d * 1000; - } - - public static int hashValueFor(final char c) { - return c; - } - - public static int hashValueFor(final byte b) { - return b; - } - - public static int hashValueFor(final short s) { - return s; - } - - public static int hashValueFor(final Object o) { - if (o == null) return -1; - return o.hashCode(); - } - - public static Annotation[] getDefaultQualifiers() { - return DEFAULT_QUALIFIERS; - } - - public static Named createNamed(final String name) { - return new Named() { - - @Override - public Class annotationType() { - return Named.class; - } - - @Override - public String value() { - return name; - } - }; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/WindowInjectionContext.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/WindowInjectionContext.java deleted file mode 100644 index 569d5e5a9d5..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/WindowInjectionContext.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client; - -import jsinterop.annotations.JsType; -import org.jboss.errai.ioc.client.container.JsTypeProvider; - -/** - * Client-side global context for sharing bean definitions across different scripts. - * - * @author Christian Sadilek - * @author Max Barkley - */ -@JsType(isNative = true) -public interface WindowInjectionContext { - - boolean hasProvider(final String name); - - JsArray> getProviders(final String name); - - Object getBean(final String name); - - void addSuperTypeAlias(final String superTypeName, final String typeName); - - void addBeanProvider(final String name, final JsTypeProvider provider); - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/WindowInjectionContextImpl.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/WindowInjectionContextImpl.java deleted file mode 100644 index bcade821cf9..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/WindowInjectionContextImpl.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client; - -import java.util.List; - -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.ListMultimap; -import org.jboss.errai.ioc.client.container.IOCResolutionException; -import org.jboss.errai.ioc.client.container.JsTypeProvider; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author Christian Sadilek - * @author Max Barkley - * @see WindowInjectionContext - */ -public class WindowInjectionContextImpl implements WindowInjectionContext { - private final ListMultimap> beanProviders = ArrayListMultimap.create(); - private final Logger logger = LoggerFactory.getLogger(WindowInjectionContextImpl.class); - - public WindowInjectionContextImpl() { - logger.debug("WindowInjectionContext created."); - } - - @Override - public void addBeanProvider(final String name, final JsTypeProvider provider) { - logger.debug("Added provider {} for name {}", provider.getName(), name); - beanProviders.put(name, provider); - if (provider.getName() != null) { - beanProviders.put(provider.getName(), provider); - } - } - - @Override - public void addSuperTypeAlias(final String superTypeName, final String typeName) { - logger.debug("Added super type alias {} for type {}", superTypeName, typeName); - beanProviders.putAll(superTypeName, beanProviders.get(typeName)); - } - - @Override - public Object getBean(final String name) { - logger.debug("Looking up bean {}", name); - final List> providers = beanProviders.get(name); - - if (providers.isEmpty()) { - throw new IOCResolutionException("no matching bean instances for: " + name); - } - else if (providers.size() > 1) { - throw new IOCResolutionException("multiple matching bean instances for: " + name); - } - else { - return providers.get(0).getInstance(); - } - } - - @Override - public JsArray> getProviders(final String name) { - logger.debug("Looking up providers for {}", name); - final List> providers = beanProviders.get(name); - - logger.debug("Found {} providers: {}", providers.size(), providers); - return new JsArray<>(providers.toArray(new JsTypeProvider[providers.size()])); - } - - @Override - public boolean hasProvider(final String name) { - logger.debug("Checking for providers for {}", name); - return getProviders(name).length() > 0; - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/WindowInjectionContextStorage.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/WindowInjectionContextStorage.java deleted file mode 100644 index 18068d77b55..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/WindowInjectionContextStorage.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client; - -/** - * - * @author Max Barkley - * @see WindowInjectionContext - */ -public class WindowInjectionContextStorage { - - public static final WindowInjectionContext createOrGet() { - if (!isWindowInjectionContextDefined()) { - setWindowInjectionContext(new WindowInjectionContextImpl()); - } - return getWindowInjectionContext(); - } - - public static final void reset() { - setWindowInjectionContext(null); - } - - public static final boolean isWindowInjectionContextDefined() { - return getWindowInjectionContext() != null; - } - - public static native WindowInjectionContext getWindowInjectionContext()/*-{ - return $wnd.windowInjectionContext || null; - }-*/; - - public static native void setWindowInjectionContext(WindowInjectionContext ic)/*-{ - $wnd.windowInjectionContext = ic; - }-*/; - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/ActivatedBy.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/ActivatedBy.java deleted file mode 100644 index cee0da0928f..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/ActivatedBy.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.jboss.errai.ioc.client.container.BeanActivator; -import org.jboss.errai.ioc.client.container.SyncBeanDef; - -/** - * Registers a {@link BeanActivator} for the annotated managed bean. The provided activator will be - * used at runtime for checking whether or not the managed IOC bean is activated (see - * {@link SyncBeanDef#isActivated()}). - * - * Note that the managed IOC bean can be asynchronously loaded (when annotated with - * {@link LoadAsync}), but the activator itself can not. - * - * @author Christian Sadilek - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -@Inherited -public @interface ActivatedBy { - - /** - * The activator type to use. Instances are managed by Errai IOC. - */ - Class value(); - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/AfterInitialization.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/AfterInitialization.java deleted file mode 100644 index 64b7459fdbc..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/AfterInitialization.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Specifies that the annotated method should be called by the framework once - * the local ErraiBus has completed initialization and has federated with the - * remote server bus. - *

- * Methods annotated with {@code @AfterInitialization} must observe the - * following contract: - *

    - *
  1. The annotated method may be public, protected or private.
  2. - *
  3. The method must NOT be static.
  4. - *
  5. The method must NOT accept any parameters.
  6. - *
  7. The return type MUST be void.
  8. - *
  9. Execution order of AfterInitialization annotated methods - * relative to each other is NOT guaranteed in any way.
  10. - *
- * - * @author Mike Brock - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface AfterInitialization { -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/CodeDecorator.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/CodeDecorator.java deleted file mode 100644 index c8d14c9a939..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/CodeDecorator.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface CodeDecorator { - int order() default 0; -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/ContextualTypeProvider.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/ContextualTypeProvider.java deleted file mode 100644 index 8d2f98db736..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/ContextualTypeProvider.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api; - -import java.lang.annotation.Annotation; - -/** - * A contextual type provider is a provider which receives contextual information about the injection point which - * is being satisfied with this provider. The provider provides two pieces of contextual information: the raw class - * values of the most outer type arguments (if present) of the type of the injection point, as well as any - * qualifiers at that injection point. - * - * @param the type provided by this class - * @see IOCProvider - */ -public interface ContextualTypeProvider { - /** - * Called to provide an instance of the type provided for by this type provider. This method accepts two arguments - * which are provided by the container at runtime, describing the type arguments and qualifiers at the injection - * point. - * - * @param typeargs the raw class values of the outer-most type arguments. For example, if the injection point - * is of the type Map<String, List<? extends Number<>> then the values - * passed to this argument will be [String.class, List.class]. - * - * @param qualifiers and array of qualifiers at the injection point. - * - * @return the type produced by this provider. - */ - public T provide(Class[] typeargs, Annotation[] qualifiers); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/Disposer.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/Disposer.java deleted file mode 100644 index 406c73f7834..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/Disposer.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api; - -/** - * A disposer exposes the bean managers explicit disposal functionality. An injected disposer can be used to - * dispose of the parameterized bean type. - * - * @author Mike Brock - */ -public interface Disposer { - - /** - * Requests that the bean manager dispose of the specified bean instance. - * - * @param beanInstance the instance of the bean to be disposed. - */ - public void dispose(T beanInstance); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/EnabledByProperty.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/EnabledByProperty.java deleted file mode 100644 index 3f8a41d5d8d..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/EnabledByProperty.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Indicates that the target Errai IOC bean can be switched on and off at GWT rebind time - * by setting a Java System Property. - * - * @author Mike Brock - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface EnabledByProperty { - - /** - * The name of the system property that enables or disables this bean. - */ - String value(); - - /** - * Normally, the target bean is enabled if the specified system property exists and - * matches the declared {@code matchValue}. If {@code negated} is {@code true} - * then this sense is reversed: the bean is disabled if the specified system property - * equals the {@code matchValue}. - */ - boolean negated() default false; - - /** - * When enabled, the matchValue is used as the default value in case the system property is not set. - */ - boolean matchByDefault() default false; - - /** - * Whether it should consider case sensitive when comparing the match value. - */ - boolean caseSensitive() default false; - - /** - * Expected property value to match for considering this bean enabled - */ - String matchValue() default "true"; - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/EntryPoint.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/EntryPoint.java deleted file mode 100644 index ca3779c8232..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/EntryPoint.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import javax.inject.Scope; - -/** - * Specifies that the annotated bean is an application entry point. Beans - * annotated with {@code @EntryPoint} are instantiated when the client-side - * application is first loaded. At the time an Entry Point bean is first - * instantiated, the client has not yet federated with the server bus, so remote - * service names are not yet known. Most often, initialization code should be - * placed in a method annotated with {@link AfterInitialization} rather than in - * the bean's constructor. - * - * @see AfterInitialization - */ -@Scope -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface EntryPoint { -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/IOCBootstrapTask.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/IOCBootstrapTask.java deleted file mode 100644 index a646f08e50a..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/IOCBootstrapTask.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * @author Mike Brock - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface IOCBootstrapTask { - TaskOrder value(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/IOCExtension.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/IOCExtension.java deleted file mode 100644 index fb274148460..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/IOCExtension.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * This annotation indicates that the annotated class is an IOC extension module and should be instantiated and - * its method invoked as part of the IOC container initialization. - * - * @see org.jboss.errai.ioc.rebind.ioc.extension.IOCExtensionConfigurator - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface IOCExtension { -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/IOCProvider.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/IOCProvider.java deleted file mode 100644 index 01b40eac56d..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/IOCProvider.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Defines a top-level provider for the IOC Container. Top-level providers are a special feature of the container - * used for defining injectable beans which are available anywhere within the container, from any scope, at any - * point of the runtime lifecycle. - *

- * Top-level providers are used for defining framework-level features such as support for injecting instances of - * the MessageBus or the RPC Callable interface. - *

- * The production of top-level providers are not managed beans. But the instances of the top-level providers - * are themselves, managed and are scopable. Thus, all top-level providers that do not declare an explicit scope are - * of the pseudo-dependant scope and are instantiated prior to all invocations of the provider. - *

- * Classes which are annotated with @IOCProvider MUST implement either: - *

    - *
  • {@link javax.inject.Provider}
  • - *
  • {@link ContextualTypeProvider}
  • - *
- * - * A provider can also implement {@link Disposer}, allowing it to clean up resources when a provided bean is destroyed. - * - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface IOCProvider { -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/InitBallot.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/InitBallot.java deleted file mode 100644 index d08a3f3edd8..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/InitBallot.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api; - -/** - * An InitBallot is injected by the container into a bean which declares a dependency on it. By doing so, the bean - * enjoins itself into the startup contract of the framework services. Thus, it is expected to call {@link #voteForInit()} - * to indicate that it is okay to proceed with initialization. The class must be parameterized with a class which - * represents the startup dependency. - *

- * The container imposes a fixed amount of time for which there must be a call to {@link #voteForInit()}. If the call - * is not made within this time period, then the dependency will be deemed unsatisified and the container will produce - * an error. - * - * @param A type reference to be used to uniquely identify the dependency. This is typically the same class - * which declares the InitBallot, but not necessarily. If more than component injects an - * InitBallot with the same type parameter, they will all represent the same dependency. - * @author Mike Brock - */ -public interface InitBallot { - /** - * When called, the class's lock on the startup procedure for framework services is released. - */ - public void voteForInit(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/InjectionException.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/InjectionException.java deleted file mode 100644 index 9b0be5cd422..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/InjectionException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api; - -/** - * @author Mike Brock - */ -public class InjectionException extends RuntimeException { - - public InjectionException() { - super(); - } - - public InjectionException(String message) { - super(message); - } - - public InjectionException(String message, Throwable cause) { - super(message, cause); - } - - public InjectionException(Throwable cause) { - super(cause); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/LoadAsync.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/LoadAsync.java deleted file mode 100644 index 326909f2536..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/LoadAsync.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -import com.google.gwt.core.client.GWT; - -/** - * Provides a hint to the container that the annotated element should be loaded asynchronously using - * GWT's code splitting. This annotation can be placed on any container-managed element (beans or - * producers). - * - * A fragment name can optionally be specified using a class literal. GWT's code splitter will put - * the code of all types with the same fragment name into the same code fragment see - * {@link GWT#runAsync(Class, com.google.gwt.core.client.RunAsyncCallback)}. - * - * @author Mike Brock - * @author Christian Sadilek - */ -@Retention(RetentionPolicy.RUNTIME) -@java.lang.annotation.Target({ ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER }) -public @interface LoadAsync { - - /** - * The fragment name to group all types with the same name into the same code fragment. - */ - Class value() default org.jboss.errai.ioc.client.api.LoadAsync.NO_FRAGMENT.class; - - public static abstract class NO_FRAGMENT {}; -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/ManagedInstance.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/ManagedInstance.java deleted file mode 100644 index 4b630242797..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/ManagedInstance.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api; - -import java.lang.annotation.Annotation; - -import javax.enterprise.context.Dependent; -import javax.inject.Provider; - -import org.jboss.errai.ioc.client.container.ClientBeanManager; - -/** - * This type is like {@code javax.inject.Instance} but with automatic life-cycle management. - * - * Using an {@code Instance} or the {@link ClientBeanManager} directly requires the caller to manually destroy - * created instances of {@link Dependent} scoped beans (or else risk a memory leak). - * - * A {@code ManagedInstance} holds references to every {@link Dependent} scoped bean it creates. When - * {@link #destroyAll()} is called, any {@link Dependent} scope instances created by the {@code ManagedInstance} are - * destroyed. - * - * When a {@code ManagedInstance} is injected, its {@link #destroyAll()} is automatically called when the bean - * instance in which it is injected is destroyed. In other words, the dynamically created {@link Dependent} scoped - * instances from a {@code ManagedInstance} have life-cycles bound to the bean that injected the - * {@code ManagedInstance}. - * - * @author Max Barkley - */ -public interface ManagedInstance extends Provider, Iterable { - - /** - *

- * Obtains a child ManagedInstance for the given additional required qualifiers. - *

- *

- * For {@link Dependent} beans that are created by a child ManagedInstance they will be destroyed when: - *

- *
    - *
  • {@link #destroyAll()} is called on the child ManagedInstance - *
  • {@link #destroyAll()} is called on the parent ManagedInstance - *
- *

- * Calling {@link #destroyAll()} on a child ManagedInstance does not destroy instances created by the - * parent. - *

- * - * @param qualifiers - * the additional required qualifiers - * @return the child ManagedInstance - * @throws IllegalArgumentException - * if passed two instances of the same qualifier type, or an instance of an annotation that is not a - * qualifier type - */ - public ManagedInstance select(Annotation... qualifiers); - - /** - *

- * Obtains a child Instance for the given required type and additional required qualifiers. - *

- *

- * For {@link Dependent} beans that are created by a child ManagedInstance they will be destroyed when: - *

- *
    - *
  • {@link #destroyAll()} is called on the child ManagedInstance - *
  • {@link #destroyAll()} is called on the parent ManagedInstance - *
- *

- * Calling {@link #destroyAll()} on a child ManagedInstance does not destroy instances created by the - * parent. - *

- * - * @param - * the required type - * @param subtype - * a {@link java.lang.Class} representing the required type - * @param qualifiers - * the additional required qualifiers - * @return the child Instance - * @throws IllegalArgumentException - * if passed two instances of the same qualifier type, or an instance of an annotation that is not a - * qualifier type - */ - public ManagedInstance select(Class subtype, Annotation... qualifiers); - - /** - *

- * Determines if there is no bean that matches the required type and qualifiers and is eligible for injection into the - * class into which the parent Instance was injected. - *

- * - * @return true if there is no bean that matches the required type and qualifiers and is eligible for - * injection into the class into which the parent Instance was injected, or false otherwise. - */ - public boolean isUnsatisfied(); - - /** - *

- * Determines if there is more than one bean that matches the required type and qualifiers and is eligible for - * injection into the class into which the parent Instance was injected. - *

- * - * @return true if there is more than one bean that matches the required type and qualifiers and is eligible - * for injection into the class into which the parent Instance was injected, or false - * otherwise. - */ - public boolean isAmbiguous(); - - /** - *

- * Destroys a {@link Dependent} scoped bean instance created by this ManagedInstance. If the argument of this - * method is not a {@link Dependent} scoped bean created by this ManagedInstance then this method is a no-op. - *

- * - * @param A {@link Dependent} scoped bean instance created by this ManagedInstance (or else this method is a no-op). - */ - public void destroy(T instance); - - /** - *

- * Destroy every {@link Dependent} scoped bean instance created by this and any child ManagedInstances. - *

- *

- * For an injected ManagedInstance this method is automatically called when the bean instance in which it is - * injected is destroyed. - *

- */ - public void destroyAll(); - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/ReplyTo.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/ReplyTo.java deleted file mode 100644 index b2e5eef7efc..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/ReplyTo.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -import javax.inject.Qualifier; - -/** - * A qualifying annotation to be used with the - * - * @author Mike Brock - */ -@Retention(RetentionPolicy.RUNTIME) -@Qualifier -@java.lang.annotation.Target(ElementType.FIELD) -public @interface ReplyTo { - String value(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/ScopeContext.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/ScopeContext.java deleted file mode 100644 index f00fd2b90a7..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/ScopeContext.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api; - -import java.lang.annotation.Annotation; -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.jboss.errai.ioc.client.container.Context; - -/** - * This annotation is used to declare that an implementation of {@link Context} - * should be used to handle some given set of scopes. - * - * At runtime, a bean will be assigned to the scope of the {@link Context} - * implementation that contained the bean's scope annotation in the context's - * {@link ScopeContext#value()}. - * - *@see Context - * @author Max Barkley - */ -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface ScopeContext { - - /** - * @return An array of scope annotations for which the annotated - * {@link Context} implementation is responsible. - */ - Class[] value(); - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/Shared.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/Shared.java deleted file mode 100644 index 39dea28cfa1..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/Shared.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import javax.inject.Qualifier; - -import jsinterop.annotations.JsType; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.PARAMETER; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -/** - * A qualifier indicating that the injected type should be satisfied by a - * {@link JsType} instance provided by a a separately compiled script if - * available. - * - * This is useful when you have a locally defined type that implements a - * {@link JsType} interface. In this case adding {@link Shared} to an injection - * site ensures that an external implementation is used (if one exists) rather - * than the local non-JsType one. - * - * @author Max Barkley - * @author Christian Sadilek - */ -@Documented -@Qualifier -@Retention(RUNTIME) -@Target({ FIELD, PARAMETER }) -public @interface Shared { - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/SharedSingleton.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/SharedSingleton.java deleted file mode 100644 index c400b510d9e..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/SharedSingleton.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api; - -import java.lang.annotation.Documented; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.context.NormalScope; - -import jsinterop.annotations.JsType; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -/** - * Within a single compiled GWT script this scope is synonymous with - * {@link ApplicationScoped}. - * - * When multiple separately compiled GWT scripts are loaded on a page, this - * scope indicates that there should be exactly one instance of this bean used - * to satisfy {@link Shared} injection points in all of the scripts, for all - * injection sites using {@link JsType}s. - * - * If both scripts are compiled with the same {@link SharedSingleton} type, the - * instance in the script executing first will be used. - * - * @author Max Barkley - * @author Christian Sadilek - */ -@Documented -@Retention(RUNTIME) -@Target({ TYPE, METHOD, FIELD }) -@NormalScope -@Inherited -public @interface SharedSingleton { - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/TaskOrder.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/TaskOrder.java deleted file mode 100644 index 8e876db77fc..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/TaskOrder.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api; - -/** - * @author Mike Brock - */ -public enum TaskOrder { - Before, After -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/TestOnly.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/TestOnly.java deleted file mode 100644 index 094f9ea4662..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/TestOnly.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Some IDEs and some environments may improperly add test classes to the classpath in development mode. This - * clarifying annotation tells the IOC container not to consider beans annotated with this annotation unless - * they are running within the test environment. - * - * @author Mike Brock - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface TestOnly { -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/Timed.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/Timed.java deleted file mode 100644 index 84984d52d6f..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/Timed.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.jboss.errai.common.client.util.TimeUnit; - -/** - * Specifies a timed method invocation of a method on a managed bean. Timed methods are tied to the lifecycle of - * the bean which they are declared on. Therefore, repeating timers cannot be stopped unless the host bean is - * destroyed. - * - * @author Mike Brock - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface Timed { - /** - * The type of timer to run. Either repeating or absolute. - * - * @return the {@link TimerType} - */ - TimerType type(); - - /** - * The time unit of the specified interval. - * - * @return the time unit - */ - TimeUnit timeUnit(); - - /** - * The interval of the timer. - * - * @return the interval - */ - int interval(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/TimerType.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/TimerType.java deleted file mode 100644 index a86b816480c..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/TimerType.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api; - -/** - * @author Mike Brock - */ -public enum TimerType { - /** - * A delay timer, relative to the creation of the bean. - */ - DELAYED, - - /** - * A repeating timer, with the first invocation relative to the creation of the bean. - */ - REPEATING -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/ToSubject.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/ToSubject.java deleted file mode 100644 index 2af86971e30..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/ToSubject.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -import javax.inject.Qualifier; - -/** - * @author Mike Brock . - */ -@Retention(RetentionPolicy.RUNTIME) -@Qualifier -@java.lang.annotation.Target(ElementType.FIELD) -public @interface ToSubject { - String value(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/UncaughtExceptionHandler.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/UncaughtExceptionHandler.java deleted file mode 100644 index 92c8a19bfbd..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/UncaughtExceptionHandler.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.context.Dependent; -import javax.inject.Singleton; - -import com.google.gwt.core.client.GWT; -import org.jboss.errai.ioc.client.container.ErraiUncaughtExceptionHandler; - -/** - *

- * Indicates that the annotated method should be invoked when an uncaught exception occurs in the client-side message - * bus or an uncaught exception occurs in client code. - * - *

- * Before the IOC container starts, an {@link ErraiUncaughtExceptionHandler} is set via - * {@link GWT#setUncaughtExceptionHandler(com.google.gwt.core.client.GWT.UncaughtExceptionHandler)}, which dispatches to - * all {@link UncaughtExceptionHandler} methods. - * - *

- * The annotated method needs to have exactly one parameter of type {@link Throwable}. - * - *

- * For {@link ApplicationScoped}, {@link EntryPoint}, and {@link Singleton} beans, the handler method is always called - * on the same instance. An uncaught exception will force the creation of the bean instance if it has not already been - * instantiated. - * - *

- * For {@link Dependent} beans, only already existing instances will have their handler methods invoked. If multiple - * instances exist for a type with a handler method, all instances will have their handler methods called. If none - * exist, then no handler methods for that type will be called. - * - * @author Christian Sadilek - * @author Max Barkley - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.METHOD }) -public @interface UncaughtExceptionHandler { -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/builtin/AsyncBeanManagerProvider.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/builtin/AsyncBeanManagerProvider.java deleted file mode 100644 index 9de2da4af9b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/builtin/AsyncBeanManagerProvider.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api.builtin; - -import javax.inject.Singleton; - -import org.jboss.errai.common.client.api.annotations.IOCProducer; -import org.jboss.errai.ioc.client.api.EnabledByProperty; -import org.jboss.errai.ioc.client.container.IOC; -import org.jboss.errai.ioc.client.container.async.AsyncBeanManager; - -/** - * @author Mike Brock - */ -@Singleton -@EnabledByProperty(value = "errai.ioc.async_bean_manager") -public class AsyncBeanManagerProvider { - - @IOCProducer - public AsyncBeanManager get() { - return IOC.getAsyncBeanManager(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/builtin/AsyncDisposerProvider.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/builtin/AsyncDisposerProvider.java deleted file mode 100644 index 72f9ea6a89b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/builtin/AsyncDisposerProvider.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api.builtin; - -import java.lang.annotation.Annotation; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jboss.errai.ioc.client.api.ContextualTypeProvider; -import org.jboss.errai.ioc.client.api.Disposer; -import org.jboss.errai.ioc.client.api.EnabledByProperty; -import org.jboss.errai.ioc.client.api.IOCProvider; -import org.jboss.errai.ioc.client.container.async.AsyncBeanManager; - -/** - * @author Mike Brock - */ -@IOCProvider -@Singleton -@EnabledByProperty("errai.ioc.async_bean_manager") -public class AsyncDisposerProvider implements ContextualTypeProvider { - @Inject - AsyncBeanManager beanManager; - - @Override - public Disposer provide(final Class[] typeargs, final Annotation[] qualifiers) { - return new Disposer() { - @Override - public void dispose(Object beanInstance) { - beanManager.destroyBean(beanInstance); - } - }; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/builtin/CallerProvider.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/builtin/CallerProvider.java deleted file mode 100644 index 28778159567..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/builtin/CallerProvider.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api.builtin; - -import java.lang.annotation.Annotation; - -import javax.inject.Singleton; - -import org.jboss.errai.common.client.api.Caller; -import org.jboss.errai.common.client.api.ErrorCallback; -import org.jboss.errai.common.client.api.NoOpCallback; -import org.jboss.errai.common.client.api.RemoteCallback; -import org.jboss.errai.common.client.framework.RemoteServiceProxyFactory; -import org.jboss.errai.common.client.framework.RpcStub; -import org.jboss.errai.ioc.client.api.ContextualTypeProvider; -import org.jboss.errai.ioc.client.api.Disposer; -import org.jboss.errai.ioc.client.api.IOCProvider; - -/** - * @author Mike Brock - * @author Max Barkley - */ -@IOCProvider @Singleton -@SuppressWarnings("rawtypes") -public class CallerProvider implements ContextualTypeProvider, Disposer { - - private static final RemoteServiceProxyFactory factory = new RemoteServiceProxyFactory(); - - @Override - public Caller provide(final Class[] typeargs, final Annotation[] qualifiers) { - return new CallerImplementation(qualifiers, typeargs); - } - - @Override - public void dispose(final Caller beanInstance) { - if (beanInstance instanceof CallerImplementation) { - ((CallerImplementation) beanInstance).dispose(); - } - } - - private final class CallerImplementation implements Caller { - private final Annotation[] qualifiers; - private final Class[] typeargs; - private boolean enabled = true; - - private CallerImplementation(final Annotation[] qualifiers, final Class[] typeargs) { - this.qualifiers = qualifiers; - this.typeargs = typeargs; - } - - @Override - public Object call() { - final Object proxy = factory.getRemoteProxy(typeargs[0]); - ((RpcStub) proxy).setRemoteCallback(new NoOpCallback()); - ((RpcStub) proxy).setQualifiers(qualifiers); - return proxy; - } - - @Override - public Object call(final RemoteCallback callback) { - final Object proxy = factory.getRemoteProxy(typeargs[0]); - ((RpcStub) proxy).setRemoteCallback(wrap(callback)); - ((RpcStub) proxy).setQualifiers(qualifiers); - return proxy; - } - - @Override - public Object call(final RemoteCallback callback, final ErrorCallback errorCallback) { - final Object proxy = factory.getRemoteProxy(typeargs[0]); - ((RpcStub) proxy).setRemoteCallback(wrap(callback)); - ((RpcStub) proxy).setErrorCallback(wrap(errorCallback)); - ((RpcStub) proxy).setQualifiers(qualifiers); - return proxy; - } - - private RemoteCallback wrap(final RemoteCallback wrapped) { - return retVal -> { - if (enabled) { - wrapped.callback(retVal); - } - }; - } - - private ErrorCallback wrap(final ErrorCallback wrapped) { - return (msg, error) -> { - return !enabled || wrapped.error(msg, error); - }; - } - - public void dispose() { - enabled = false; - } - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/builtin/DisposerProvider.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/builtin/DisposerProvider.java deleted file mode 100644 index 552e50bf7ba..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/builtin/DisposerProvider.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api.builtin; - -import java.lang.annotation.Annotation; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jboss.errai.ioc.client.api.ContextualTypeProvider; -import org.jboss.errai.ioc.client.api.Disposer; -import org.jboss.errai.ioc.client.api.EnabledByProperty; -import org.jboss.errai.ioc.client.api.IOCProvider; -import org.jboss.errai.ioc.client.container.SyncBeanManager; - -/** - * @author Mike Brock - */ -@IOCProvider -@Singleton -@EnabledByProperty(value = "errai.ioc.async_bean_manager", negated = true) -public class DisposerProvider implements ContextualTypeProvider { - @Inject - SyncBeanManager beanManager; - - @Override - public Disposer provide(final Class[] typeArguments, final Annotation[] qualifiers) { - return new Disposer() { - @Override - public void dispose(final Object beanInstance) { - beanManager.destroyBean(beanInstance); - } - }; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/builtin/DummyJsTypeProvider.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/builtin/DummyJsTypeProvider.java deleted file mode 100644 index 7808054cca3..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/builtin/DummyJsTypeProvider.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api.builtin; - -import org.jboss.errai.ioc.client.JsArray; -import org.jboss.errai.ioc.client.container.JsTypeProvider; - -/** - * - * @author Max Barkley - */ -public abstract class DummyJsTypeProvider implements JsTypeProvider { - - @Override - public String getFactoryName() { - return null; - } - - @Override - public JsArray getQualifiers() { - return new JsArray<>(new String[0]); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/builtin/IOCBeanManagerProvider.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/builtin/IOCBeanManagerProvider.java deleted file mode 100644 index 38cb4610603..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/builtin/IOCBeanManagerProvider.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api.builtin; - -import javax.inject.Singleton; - -import org.jboss.errai.common.client.api.annotations.IOCProducer; -import org.jboss.errai.ioc.client.api.EnabledByProperty; -import org.jboss.errai.ioc.client.container.IOC; -import org.jboss.errai.ioc.client.container.SyncBeanManager; - -/** - * @author Mike Brock - */ -@Singleton -@EnabledByProperty(value = "errai.ioc.async_bean_manager", negated = true) -public class IOCBeanManagerProvider { - - @IOCProducer - public SyncBeanManager get() { - return IOC.getBeanManager(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/builtin/InitBallotProvider.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/builtin/InitBallotProvider.java deleted file mode 100644 index 62e52c99610..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/builtin/InitBallotProvider.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api.builtin; - -import java.lang.annotation.Annotation; - -import javax.inject.Singleton; - -import org.jboss.errai.common.client.api.extension.InitVotes; -import org.jboss.errai.ioc.client.api.ContextualTypeProvider; -import org.jboss.errai.ioc.client.api.IOCProvider; -import org.jboss.errai.ioc.client.api.InitBallot; - -/** - * @author Mike Brock . - */ -@Singleton -@IOCProvider -public class InitBallotProvider implements ContextualTypeProvider> { - @Override - public InitBallot provide(final Class[] typeArguments, final Annotation[] qualifiers) { - InitVotes.waitFor(typeArguments[0]); - - return new InitBallot() { - @Override - public void voteForInit() { - InitVotes.voteFor(typeArguments[0]); - } - }; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/builtin/ManagedInstanceProvider.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/builtin/ManagedInstanceProvider.java deleted file mode 100644 index dfe8201c48b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/builtin/ManagedInstanceProvider.java +++ /dev/null @@ -1,278 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api.builtin; - -import java.lang.annotation.Annotation; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import javax.enterprise.context.Dependent; - -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.Multimap; -import org.jboss.errai.ioc.client.IOCUtil; -import org.jboss.errai.ioc.client.api.ContextualTypeProvider; -import org.jboss.errai.ioc.client.api.Disposer; -import org.jboss.errai.ioc.client.api.IOCProvider; -import org.jboss.errai.ioc.client.api.ManagedInstance; -import org.jboss.errai.ioc.client.container.SyncBeanDef; - -import static org.jboss.errai.ioc.client.QualifierUtil.DEFAULT_ANNOTATION; -import static org.jboss.errai.ioc.client.container.IOC.getBeanManager; - -@IOCProvider -public class ManagedInstanceProvider implements ContextualTypeProvider>, Disposer> { - - @Override - @SuppressWarnings({ "rawtypes", "unchecked" }) - public ManagedInstance provide(final Class[] typeargs, final Annotation[] qualifiers) { - return new ManagedInstanceImpl(typeargs[0], qualifiers.length == 0 ? new Annotation[] { DEFAULT_ANNOTATION } : qualifiers); - } - - @Override - public void dispose(final ManagedInstance managedInstance) { - managedInstance.destroyAll(); - } - - private static final Map, SubTypeNode> subTypeNodes = new HashMap<>(); - - private static void addSubTypeRelation(final Class superType, final Class subType) { - if (!superType.equals(subType)) { - SubTypeNode superNode = subTypeNodes.get(superType); - if (superNode == null) { - superNode = new SubTypeNode(superType, new LinkedHashSet<>(0)); - subTypeNodes.put(superType, superNode); - } - SubTypeNode subNode = subTypeNodes.get(subType); - if (subNode == null) { - subNode = new SubTypeNode(subType, new LinkedHashSet<>(1)); - subTypeNodes.put(subType, subNode); - } - subNode.superTypes.add(superNode); - } - } - - private static boolean isSubTypeRelation(final Class superType, final Class subType) { - if (superType.equals(subType)) { - return true; - } - else { - final SubTypeNode superNode = subTypeNodes.get(superType); - final SubTypeNode subNode = subTypeNodes.get(subType); - - return superNode != null && subNode != null && isSubTypeRelation(superNode, subNode); - } - } - - private static boolean isSubTypeRelation(final SubTypeNode superNode, final SubTypeNode subNode) { - if (subNode.superTypes.contains(superNode)) { - return true; - } - else { - for (final SubTypeNode node : subNode.superTypes) { - if (isSubTypeRelation(superNode, node)) { - return true; - } - } - - return false; - } - } - - private static class SubTypeNode { - private final Class type; - private final Set superTypes; - - private SubTypeNode(final Class type, final Set superTypes) { - this.type = type; - this.superTypes = superTypes; - } - - @Override - public int hashCode() { - return type.hashCode(); - } - - @Override - public boolean equals(final Object obj) { - return obj instanceof SubTypeNode && ((SubTypeNode) obj).type.equals(type); - } - } - - private static class InstanceKey { - private final Class type; - private final Set qualifiers; - - private InstanceKey(final Class type, final Set qualifiers) { - this.type = type; - this.qualifiers = qualifiers; - } - - @Override - public boolean equals(final Object obj) { - if (obj instanceof InstanceKey) { - final InstanceKey other = (InstanceKey) obj; - return type.equals(other.type) && qualifiers.equals(other.qualifiers); - } - else { - return false; - } - } - - @Override - public int hashCode() { - return type.hashCode() ^ qualifiers.hashCode(); - } - } - - private static class ManagedInstanceImpl implements ManagedInstance { - - private final InstanceKey key; - private final Multimap, ? super T> dependentInstances; - - private ManagedInstanceImpl(final Class type, final Annotation[] qualifiers) { - this(type, qualifiers, ArrayListMultimap.create()); - } - - private ManagedInstanceImpl(final Class type, final Annotation[] qualifiers, final Multimap, ? super T> dependentInstances) { - this(type, new HashSet<>(Arrays.asList(qualifiers)), dependentInstances); - } - - private ManagedInstanceImpl(final Class type, final Set qualifiers, final Multimap, ? super T> dependentInstances) { - this.key = new InstanceKey<>(type, qualifiers); - this.dependentInstances = dependentInstances; - } - - @Override - public T get() { - final SyncBeanDef bean = IOCUtil.getSyncBean(key.type, qualifierArray()); - final T instance = bean.getInstance(); - if (Dependent.class.equals(bean.getScope())) { - dependentInstances.put(key, instance); - } - - return instance; - } - - private Annotation[] qualifierArray() { - return key.qualifiers.toArray(new Annotation[key.qualifiers.size()]); - } - - @Override - public Iterator iterator() { - return new ManagedInstanceImplIterator<>(getBeanManager().lookupBeans(key.type, qualifierArray()), key, dependentInstances); - } - - @Override - public ManagedInstance select(final Annotation... qualifiers) { - return select(key.type, qualifiers); - } - - @Override - public ManagedInstance select(final Class subtype, final Annotation... qualifiers) { - final Set combined = new HashSet<>(key.qualifiers); - combined.addAll(Arrays.asList(qualifiers)); - addSubTypeRelation(key.type, subtype); - return new ManagedInstanceImpl<>(subtype, combined, dependentInstances); - } - - @Override - public boolean isUnsatisfied() { - return IOCUtil.isUnsatisfied(key.type, qualifierArray()); - } - - @Override - public boolean isAmbiguous() { - return IOCUtil.isAmbiguous(key.type, qualifierArray()); - } - - @Override - public void destroy(final T instance) { - IOCUtil.destroy(instance); - dependentInstances.remove(key, instance); - } - - @Override - public void destroyAll() { - final Iterator> keysIter = dependentInstances.keySet().iterator(); - while (keysIter.hasNext()) { - final InstanceKey key = keysIter.next(); - final Set quals = key.qualifiers; - if (quals.containsAll(this.key.qualifiers) && isSubTypeRelation(this.key.type, key.type)) { - final Collection instances = dependentInstances.get(key); - for (final Object instance : instances) { - IOCUtil.destroy(instance); - } - keysIter.remove(); - } - } - } - - private static class ManagedInstanceImplIterator implements Iterator { - - private final Iterator> delegate; - private final InstanceKey key; - private final Multimap, ? super T> dependentInstances; - private Object lastCreatedInstance; - - private ManagedInstanceImplIterator(final Collection> beanDefs, final InstanceKey key, - final Multimap, ? super T> dependentInstances) { - this.key = key; - this.delegate = beanDefs.iterator(); - this.dependentInstances = dependentInstances; - } - - @Override - public boolean hasNext() { - return delegate.hasNext(); - } - - @Override - public T next() { - final SyncBeanDef bean = delegate.next(); - final T instance = bean.getInstance(); - if (Dependent.class.equals(bean.getScope())) { - dependentInstances.put(key, instance); - } - lastCreatedInstance = instance; - return instance; - } - - @Override - public void remove() { - if (lastCreatedInstance == null) { - throw new IllegalStateException(); - } - else if (dependentInstances.remove(key, lastCreatedInstance)) { - IOCUtil.destroy(lastCreatedInstance); - lastCreatedInstance = null; - } - } - } - - } -} \ No newline at end of file diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/builtin/RootPanelProvider.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/builtin/RootPanelProvider.java deleted file mode 100644 index e742becc798..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/api/builtin/RootPanelProvider.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.api.builtin; - -import javax.inject.Provider; -import javax.inject.Singleton; - -import com.google.gwt.user.client.ui.RootPanel; -import org.jboss.errai.ioc.client.api.IOCProvider; - -/** - * @author Mike Brock - */ -@IOCProvider -@Singleton -public class RootPanelProvider implements Provider { - @Override - public RootPanel get() { - return RootPanel.get(); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/AbstractContext.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/AbstractContext.java deleted file mode 100644 index c67080b1e20..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/AbstractContext.java +++ /dev/null @@ -1,269 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container; - -import java.util.Collection; -import java.util.Collections; -import java.util.Deque; -import java.util.HashMap; -import java.util.HashSet; -import java.util.IdentityHashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.LinkedList; -import java.util.Map; -import java.util.Optional; -import java.util.Set; - -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.ListMultimap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Base class used by {@link ApplicationScopedContext} and - * {@link DependentScopeContext}. Maps created proxies and instances to - * factories. - * - * @author Max Barkley - */ -public abstract class AbstractContext implements Context { - - private final Map> factories = new HashMap<>(); - private final Map> proxies = new LinkedHashMap<>(); - - /* - * This field must map to Deque> to handle producer methods returning types - * that are already managed beans, where it is possible for a context to have the same - * managed bean as belonging to two factories. - */ - private final Map>> factoriesByCreatedInstances = new IdentityHashMap<>(); - - private final Set factoriesCurrentlyCreatingInstances = new HashSet<>(); - private final ListMultimap> destructionCallbacksByInstance = ArrayListMultimap.create(); - - private final Logger logger = LoggerFactory.getLogger(getClass()); - - private ContextManager contextManager; - - @Override - public T getActiveNonProxiedInstance(final String factoryName) { - if (hasActiveInstance(factoryName)) { - return getActiveInstance(factoryName); - } else if (isCurrentlyCreatingActiveInstance(factoryName)) { - final Factory factory = this.getFactory(factoryName); - final T incomplete = factory.getIncompleteInstance(); - if (incomplete == null) { - throw new RuntimeException("Could not obtain an incomplete instance of " + factory.getHandle().getActualType().getName() + " to break a circular injection."); - } else { - logger.warn("An incomplete " + factory.getHandle().getActualType() + " was required to break a circular injection."); - return incomplete; - } - } else { - return createNewUnproxiedInstance(factoryName); - } - } - - protected T createNewUnproxiedInstance(final String factoryName) { - final Factory factory = this.getFactory(factoryName); - registerIncompleteInstance(factoryName); - final T instance = factory.createInstance(getContextManager()); - unregisterIncompleteInstance(factoryName, instance); - registerInstance(instance, factory); - factory.invokePostConstructs(instance); - return instance; - } - - protected abstract T getActiveInstance(final String factoryName); - - protected abstract boolean hasActiveInstance(final String factoryName); - - private void registerIncompleteInstance(final String factoryName) { - factoriesCurrentlyCreatingInstances.add(factoryName); - } - - private void unregisterIncompleteInstance(final String factoryName, final Object instance) { - factoriesCurrentlyCreatingInstances.remove(factoryName); - } - - protected boolean isCurrentlyCreatingActiveInstance(final String factoryName) { - return factoriesCurrentlyCreatingInstances.contains(factoryName); - } - - @Override - public ContextManager getContextManager() { - if (contextManager == null) { - throw new RuntimeException("ContextManager has not been set."); - } - - return contextManager; - } - - @Override - public void setContextManager(final ContextManager contextManager) { - this.contextManager = contextManager; - } - - @Override - public void registerFactory(final Factory factory) { - factories.put(factory.getHandle().getFactoryName(), factory); - } - - @Override - public T getInstance(final String factoryName) { - final Proxy proxy = getOrCreateProxy(factoryName); - if (proxy == null) { - return getActiveNonProxiedInstance(factoryName); - } else { - return proxy.asBeanType(); - } - } - - /** - * @return Returns null if a proxy cannot be created. - */ - protected Proxy getOrCreateProxy(final String factoryName) { - // TODO this will not work for @Dependent proxied beans. - @SuppressWarnings("unchecked") - Proxy proxy = (Proxy) proxies.get(factoryName); - if (proxy == null) { - final Factory factory = getFactory(factoryName); - proxy = factory.createProxy(this); - if (proxy != null) { - proxies.put(factoryName, proxy); - } - } - - return proxy; - } - - protected Factory getFactory(final String factoryName) { - @SuppressWarnings("unchecked") - final Factory factory = (Factory) factories.get(factoryName); - if (factory == null) { - throw new RuntimeException("Could not find registered factory " + factoryName); - } - - return factory; - } - - @Override - public Collection> getAllFactories() { - return Collections.unmodifiableCollection(factories.values()); - } - - @Override - public T getNewInstance(final String factoryName) { - final Factory factory = getFactory(factoryName); - final Proxy proxy = factory.createProxy(this); - final T instance = factory.createInstance(getContextManager()); - if (proxy != null) { - proxy.setInstance(instance); - } - factory.invokePostConstructs(instance); - registerInstance(instance, factory); - - return (proxy != null) ? proxy.asBeanType() : instance; - } - - protected void registerInstance(final Object unwrappedInstance, final Factory factory) { - Deque> stack = factoriesByCreatedInstances.get(unwrappedInstance); - if (stack == null) { - stack = new LinkedList<>(); - factoriesByCreatedInstances.put(unwrappedInstance, stack); - } - stack.push(factory); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - public void destroyInstance(final Object instance) { - if (isManaged(instance)) { - beforeDestroyInstance(instance); - final Object unwrapped = maybeUnwrap(instance); - final Deque> factories = factoriesByCreatedInstances.remove(unwrapped); - while (factories != null && !factories.isEmpty()) { - final Factory factory = factories.pop(); - for (final DestructionCallback callback : destructionCallbacksByInstance.removeAll(unwrapped)) { - callback.destroy(unwrapped); - } - factory.destroyInstance(unwrapped, contextManager); - } - afterDestroyInstance(instance); - } - } - - protected void beforeDestroyInstance(final Object instance) {} - protected void afterDestroyInstance(final Object instance) {} - - @Override - public boolean addDestructionCallback(final Object instance, final DestructionCallback callback) { - final Object unwrapped = maybeUnwrap(instance); - if (factoriesByCreatedInstances.containsKey(unwrapped)) { - destructionCallbacksByInstance.put(unwrapped, callback); - return true; - } else { - return false; - } - } - - private Object maybeUnwrap(final Object instance) { - return Factory.maybeUnwrapProxy(instance); - } - - @Override - public boolean isManaged(final Object ref) { - return (ref instanceof Proxy && ((Proxy) ref).getProxyContext() == this) - || factoriesByCreatedInstances.containsKey(ref); - } - - @SuppressWarnings("unchecked") - @Override - public

P getInstanceProperty(final Object instance, final String propertyName, final Class

type) { - final Object unwrapped = maybeUnwrap(instance); - final Deque> factories = factoriesByCreatedInstances.get(unwrapped); - if (factories != null) { - final Iterator> iter = factories.descendingIterator(); - while (iter.hasNext()) { - final P property = ((Factory) iter.next()).getReferenceAs(unwrapped, propertyName, type); - if (property != null) { - return property; - } - } - } - - return null; - } - - protected Collection> getExistingProxies() { - return proxies.values(); - } - - @Override - public Optional withContextualInstanceSupport() { - return Optional.empty(); - } - - protected void removeProxy(final Object instance) { - proxies.remove(instance); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/ApplicationScopedContext.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/ApplicationScopedContext.java deleted file mode 100644 index 909ebe4df36..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/ApplicationScopedContext.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container; - -import java.lang.annotation.Annotation; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Singleton; - -import org.jboss.errai.ioc.client.api.EntryPoint; -import org.jboss.errai.ioc.client.api.ScopeContext; -import org.jboss.errai.ioc.client.api.SharedSingleton; - -/** - * An implementation of {@link Context} for singleton beans. All calls to - * {@link #getInstance(String)} will return the same bean instance. - * - * @author Max Barkley - */ -@ScopeContext({ApplicationScoped.class, Singleton.class, EntryPoint.class, SharedSingleton.class}) -public class ApplicationScopedContext extends AbstractContext { - - private static final Set> handledScopes = new HashSet<>(); - - static { - handledScopes.add(ApplicationScoped.class); - handledScopes.add(Singleton.class); - handledScopes.add(EntryPoint.class); - } - - private final Map instances = new HashMap<>(); - - @Override - @SuppressWarnings("unchecked") - protected T getActiveInstance(final String factoryName) { - return (T) instances.get(factoryName); - } - - @Override - protected boolean hasActiveInstance(final String factoryName) { - return instances.containsKey(factoryName); - } - - @Override - protected void registerInstance(final Object unwrappedInstance, final Factory factory) { - super.registerInstance(unwrappedInstance, factory); - instances.put(factory.getHandle().getFactoryName(), unwrappedInstance); - } - - @Override - public Class getScope() { - return ApplicationScoped.class; - } - - @Override - public boolean isActive() { - return true; - } - - @Override - public boolean handlesScope(final Class scope) { - return handledScopes.contains(scope); - } - - @Override - protected void afterDestroyInstance(final Object instance) { - if (instance instanceof Proxy) { - final Proxy proxy = (Proxy) instance; - final Object rawInstance = proxy.unwrap(); - instances.values().remove(rawInstance); - proxy.clearInstance(); - } - else { - throw new IllegalArgumentException("Cannot destroy ApplicationScoped bean without reference to proxy."); - } - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/BeanActivator.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/BeanActivator.java deleted file mode 100644 index e467340f76c..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/BeanActivator.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container; - -import org.jboss.errai.ioc.client.api.ActivatedBy; -import org.jboss.errai.ioc.client.api.LoadAsync; - -/** - * Provides a runtime mechanism to check whether or not a managed bean is activated (see - * {@link ActivatedBy}). - * - * Note that the managed IOC bean can be asynchronously loaded (when annotated with - * {@link LoadAsync}), but the activator itself can not. - * - * @author Christian Sadilek - */ -public interface BeanActivator { - - /** - * @return true if the managed bean is activated, otherwise false. - */ - public boolean isActivated(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/BeanManagerSetup.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/BeanManagerSetup.java deleted file mode 100644 index b342729ced6..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/BeanManagerSetup.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container; - -public interface BeanManagerSetup { - void setContextManager(ContextManager contextManager); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/BeanManagerUtil.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/BeanManagerUtil.java deleted file mode 100644 index 5b7d24815e0..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/BeanManagerUtil.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container; - -import java.lang.annotation.Annotation; -import java.util.Collection; - -/** - * - * @author Max Barkley - */ -public class BeanManagerUtil { - - public static IOCResolutionException ambiguousResolutionException(Class type, final Collection> resolved, - Annotation... qualifiers) { - final StringBuilder builder = new StringBuilder(); - builder.append("Multiple beans matched " + type.getName() + " with qualifiers " + qualifiersToString(qualifiers) + "\n") - .append("Found:\n"); - for (final IOCBeanDef beanDef : resolved) { - builder.append(" ") - .append(beanDef.toString()) - .append("\n"); - } - IOCResolutionException iocResolutionException = new IOCResolutionException(builder.toString()); - return iocResolutionException; - } - - public static IOCResolutionException unsatisfiedResolutionException(Class type, Annotation... qualifiers) { - return new IOCResolutionException("No beans matched " + type.getName() + " with qualifiers " + qualifiersToString(qualifiers)); - } - - public static String beanDeftoString(final FactoryHandle handle) { - return "[type=" + handle.getActualType().getName() + ", qualifiers=" + handle.getQualifiers() + "]"; - } - - private static String qualifiersToString(final Annotation[] qualifiers) { - final StringBuilder builder = new StringBuilder().append("{ "); - for (final Annotation qualifier : qualifiers) { - builder.append(qualifier.annotationType().getName()) - .append(", "); - } - builder.delete(builder.length() - ", ".length(), builder.length()); - builder.append(" }"); - - return builder.toString(); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/ClientBeanManager.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/ClientBeanManager.java deleted file mode 100644 index 3d4e2031135..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/ClientBeanManager.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container; - -/** - * Contract for injectable client-side instances for run-time bean management. - * - * @author Mike Brock - * @author Max Barkley - * @author Christian Sadilek - */ -public interface ClientBeanManager { - /** - * Destroy a bean and all other dependent scoped dependencies of this bean in the bean manager. - * - * @param ref - * The instance reference of the bean. - */ - void destroyBean(Object ref); - - /** - * Indicates whether the referenced object is currently a managed bean. - * - * @param ref - * The instance reference of the bean. - * - * @return returns true if under management - */ - boolean isManaged(Object ref); - - /** - * Obtains an instance to the actual bean. If the specified reference is a proxy, this method will - * return an un-proxied reference to the object. - * - * @param ref - * The proxied or unproxied reference. - * - * @return The actual reference to the bean if the specified reference is a proxy. - * Otherwise the same instance passed to the method is returned. - * - * @see #isProxyReference(Object) - */ - Object getActualBeanReference(Object ref); - - /** - * Determines whether the referenced object is itself a proxy to a managed bean. - * - * @param ref - * The reference to check. - * - * @return True iff the specified reference is a proxy. - * - * @see #getActualBeanReference(Object) - */ - boolean isProxyReference(Object ref); - - /** - * Associates a {@link DestructionCallback} with a bean instance. If the given reference is not a managed bean, - * or the bean is no longer considered active, the method returns false. Otherwise, the method returns - * true, indicating the callback is now registered and will be called when the bean is destroyed. - * - * @param beanInstance - * The bean instance to associate the callback to. - * @param destructionCallback - * The instance of the {@link DestructionCallback}. - * - * @return true if the {@link DestructionCallback} is successfully registered for the given bean - * and false if not. - */ - boolean addDestructionCallback(Object beanInstance, DestructionCallback destructionCallback); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/Context.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/Context.java deleted file mode 100644 index 72b64fec9e2..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/Context.java +++ /dev/null @@ -1,219 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container; - -import java.lang.annotation.Annotation; -import java.util.Collection; -import java.util.Optional; - -import org.jboss.errai.ioc.client.Container; -import org.jboss.errai.ioc.client.api.ContextualTypeProvider; -import org.jboss.errai.ioc.client.api.ScopeContext; - -/** - * A {@link Context} is responsible for managing the creation and destruction of - * beans for a given set of scopes. - * - * For the most part a {@link Context} is classified by the behaviour of calling - * {@link #getInstance(String)}. For example the {@link DependentScopeContext} - * returns a new instance everytime {@link #getInstance(String)} is invoked, - * whereas the {@link ApplicationScopedContext} returns the same instance for - * every invocation. - * - * At runtime the {@link Container} all factories with their respective - * {@link Context} via {@link #registerFactory(Factory)} before any beans are - * created. - * - * Application code should not interact directly with a {@link Context}, but - * should instead use the {@link ClientBeanManager} for programmatic creation of - * beans. - * - * @see ScopeContext - * @author Max Barkley - */ -public interface Context { - - /** - * This method will only be called once at runtime, when an application is - * bootstrapping, before any bean instances are created. - * - * @param contextManager - * A reference to the application's {@link ContextManager}. - */ - void setContextManager(ContextManager contextManager); - - /** - * @return A reference to the {@link ContextManager} that was given as a - * parameter of {@link #setContextManager(ContextManager)}. - */ - ContextManager getContextManager(); - - /** - * When an application is boostrapping, this method is called for every - * {@link Factory} this {@link Context} is responsible for. This happens - * before any bean instances are created. - * - * Once a {@link Factory} is registered, it's beans should be available - * through calls to {@link #getInstance(String)} with the respective - * {@link FactoryHandle#getFactoryName() name}. - * - * @param factory - * A {@link Factory} that this {@link Context} is respon - */ - void registerFactory(Factory factory); - - /** - * Gets and instance of a bean from a {@link Factory} with the given name - * (that was previously {@link #registerFactory(Factory) registered}). - * - * @param factoryName - * The {@link FactoryHandle#getFactoryName() name} of the for the - * desired bean instance. - * @return An instance of a bean from the {@link Factory} with the given - * {@link FactoryHandle#getFactoryName() name}. This instance may or - * may not be {@link Proxy proxied}. - */ - T getInstance(String factoryName); - - /** - * Destroys a bean instance if it is {@link #isManaged(Object) managed} by - * this {@link Context}. For unmanaged beans, this is a noop. - * - * @param instance - * A bean instance to be destroyed, if {@link #isManaged(Object) - * managed} by this {@link Context}. - */ - void destroyInstance(Object instance); - - /** - * When a call to {@link #getInstance(String)} returns a {@link Proxy}, the - * proxy will eventually need to be populated. This is done in generated code - * by the {@link ProxyHelper} via a call to this method. - * - * @param factoryName - * The {@link FactoryHandle#getFactoryName() name} of a factory from - * which the returned bean instance is created. - * @return An instance of a bean that must not be a {@link Proxy}. - */ - T getActiveNonProxiedInstance(String factoryName); - - /** - * @return A representative annotation for this {@link Context}. This is only - * used for logging and error reporting. - */ - Class getScope(); - - /** - * @param scope - * A scope annotation type. - * @return True iff this context implementation handles the given scope. - */ - boolean handlesScope(Class scope); - - /** - * This method is called when a {@link ProxyHelper} attempts to populate a - * proxy. It is not called when a {@link Proxy} already contains a proxied - * instance. Therefore, when a {@link Context} becomes inactive it is its - * responsibility to {@link ProxyHelper#clearInstance() clear instances} from - * {@link Proxy proxies}. - * - * For simple contexts such as {@link ApplicationScopedContext} and - * {@link DependentScopeContext}, this method will always return true. This - * method exists to allow for future scopes of higher complexity. - * - * @return True iff this {@link Context} is currently active. - */ - boolean isActive(); - - /** - * @return Get all of the {@link Factory factories} that have been - * {@link #registerFactory(Factory) registered} with this context. - */ - Collection> getAllFactories(); - - /** - * Regardless of the behaviour of {@link #getInstance(String)} this method - * must return a previously non-existent bean instance (to support - * {@link SyncBeanDef#newInstance()}. - * - * @param factoryName - * The {@link FactoryHandle#getFactoryName() name} of a factory from - * which the returned bean instance is created. - * @return A new bean instance that may or may not be a {@link Proxy}. - */ - T getNewInstance(String factoryName); - - /** - * This method should return true if a given reference is a direct bean - * instance or a {@link Proxy}, provided the bean is from a {@link Factory} - * registered with this context. - * - * @param ref - * An object reference that may or may not be a {@link Proxy}. - * @return True iff this object is managed by this {@link Context}. - */ - boolean isManaged(Object ref); - - /** - * Used for adding {@link DestructionCallback destruction callbacks} - * programmatically at runtime. These callbacks should be invoked before a - * call to {@link #destroyInstance(Object)} returns. - * - * @param instance - * An instance managed by this context. This may or may not be a - * {@link Proxy}. - * @param callback - * A callback to be invoked when {@link #destroyInstance(Object)} is - * called for the given instance. - * @return True iff the callback was successfully registered. Should return - * false if the given instance is not managed by this context. - */ - boolean addDestructionCallback(Object instance, DestructionCallback callback); - - /** - * {@link Factory Factories} can store properties associated with instances - * they've created. This method allows factories from other contexts to access - * these stored values. - * - * @param instance - * The bean instance for which the desired property (if it exists) is - * associated. May or may not be a {@link Proxy}. - * @param propertyName - * The name of a property associated with an instance. - * @param type - * For convenince. The returned value will be cast to this type. - * @return If this instance is not managed by this context return {@code null} - * . Otherwise, return the result of - * {@link Factory#getReferenceAs(Object, String, Class)} for the - * {@link Factory} that created this bean instance. - */ -

P getInstanceProperty(Object instance, String propertyName, Class

type); - - /** - * Some contexts support contextual instances (from a {@link ContextualTypeProvider}). - * This method provides access to that aspect of the context, if supported. - * - * @return An option containing this context if contextual instances are supported, - * or else an empty option. - */ - Optional withContextualInstanceSupport(); - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/ContextManager.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/ContextManager.java deleted file mode 100644 index 3950e56c550..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/ContextManager.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container; - -import java.lang.annotation.Annotation; -import java.util.Collection; - -import org.jboss.errai.ioc.client.Container; -import org.jboss.errai.ioc.client.api.LoadAsync; - -/** - * Provides a single interface for {@link Factory factories} and the - * {@link ClientBeanManager} to get instances of beans. - * - * {@link Factory Factories} contain generated code to request instances of - * dependencies through calls to {@link #getInstance(String)}. Intances are - * created by dispatching to the appropriate {@link Context}. - * - * @author Max Barkley - */ -public interface ContextManager { - - /** - * Called for each context when the application is bootstrapping. All contexts - * are added before any instances are requested. - * - * @param context - * An implementation of {@link Context}. - */ - void addContext(Context context); - - /** - * Gets a bean instance by dispatching to the appropriate {@link Context}. - * - * @param factoryName - * The name of the {@link Factory} that creates the desired bean - * instance. - * @return A bean instance that may or may not be {@link Proxy proxied}. The - * number of unique instances returned by this method depends on the - * {@link Context} to which the factory with the given name belongs. - */ - T getInstance(String factoryName); - - /** - * Gets a contextual bean instance by dispatching to the appropriate {@link Context}. - * - * @param factoryName - * The name of the {@link Factory} that creates the desired bean - * instance. - * @param typeArgs - * The type arguments of the injection site. - * @param qualifiers - * The qualifiers of the injection site. - * @return A bean instance that may or may not be {@link Proxy proxied}. The - * number of unique instances returned by this method depends on the - * {@link Context} to which the factory with the given name belongs. - */ - T getContextualInstance(String factoryName, Class[] typeArgs, Annotation[] qualifiers); - - /** - * Like {@link #getInstance(String)} except that the returned instance is - * guaranteed to have been constructed when this method returns, even if it is - * proxied. - * - * @param factoryName - * The name of the {@link Factory} that creates the desired bean - * instance. - * @return A bean instance that may or may not be {@link Proxy proxied}. The - * number of unique instances returned by this method depends on the - * {@link Context} to which the factory with the given name belongs. - */ - T getEagerInstance(String factoryName); - - /** - * Like {@link #getInstance(String)} except that this method is guaranteed to - * return a new instance for every invocation, regardless of the behaviour of - * the {@link Context} to which the {@link Factory} belongs. - * - * @param factoryName - * The name of the {@link Factory} that creates the desired bean - * instance. - * @return A new bean instance that may or may not be {@link Proxy proxied}. - */ - T getNewInstance(String factoryName); - - /** - * @return A collection of all {@link FactoryHandle FactoryHandles}from all - * added {@link Context Contexts}. - */ - Collection getAllFactoryHandles(); - - /** - * If a bean is {@link #isManaged(Object) managed} then this method will - * invoke {@link Context#destroyInstance(Object)} for the appropriate context. - * - * @param instance - * An instance to be destroyed. May or may not be a {@link Proxy}. - */ - void destroy(Object instance); - - /** - * @param ref - * A reference to an object that may or may not have been created by - * a {@link Factory}. - * @return Returns true iff this is a bean instance or {@link Proxy} that was - * created by a {@link Factory} in some {@link Context} that has been - * added to this context manager. - */ - boolean isManaged(Object ref); - - /** - * Used for adding {@link DestructionCallback destruction callbacks} - * programmatically at runtime. These callbacks should be invoked before a - * call to {@link #destroy(Object)} returns. - * - * @param instance - * An instance managed by a context in this context manager. This may - * or may not be a {@link Proxy}. - * @param callback - * A callback to be invoked when {@link #destroyInstance(Object)} is - * called for the given instance. - * @return True iff the callback was successfully registered. Should return - * false if the given instance is not managed by any added context. - */ - boolean addDestructionCallback(Object instance, DestructionCallback callback); - - /** - * {@link Factory Factories} can store properties associated with instances - * they've created. This method allows factories to share properties with - * eachother. - * - * @param instance - * The bean instance for which the desired property (if it exists) is - * associated. May or may not be a {@link Proxy}. - * @param propertyName - * The name of a property associated with an instance. - * @param type - * For convenince. The returned value will be cast to this type. - * @return If this instance is not managed, return {@code null} . Otherwise, - * return the result of - * {@link Context#getInstanceProperty(Object, String, Class)} for the - * appropriate context. - */ -

P getInstanceProperty(Object instance, String propertyName, Class

type); - - /** - * Called once by the {@link Container} once all {@link Context contexts} have - * been initialized and added. - */ - void finishInit(); - - /** - * For adding {@link Factory factories} after {@link #finishInit()} has been - * called. Used for adding beans with {@link LoadAsync}. - * - * @param factory - * A {@link Factory} for a type with {@link LoadAsync}. - */ - void addFactory(Factory factory); - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/ContextManagerImpl.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/ContextManagerImpl.java deleted file mode 100644 index cf3faf49808..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/ContextManagerImpl.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container; - -import java.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -/** - * @see ContextManager - * @author Max Barkley - */ -public class ContextManagerImpl implements ContextManager { - - private final Map contextsByFactoryName = new HashMap(); - private final Collection contexts = new ArrayList(); - - @Override - public void addContext(final Context context) { - if (!contexts.contains(context)) { - contexts.add(context); - context.setContextManager(this); - for (final Factory factory : context.getAllFactories()) { - contextsByFactoryName.put(factory.getHandle().getFactoryName(), context); - } - } - } - - @Override - public T getInstance(final String factoryName) { - return getContext(factoryName).getInstance(factoryName); - } - - @Override - public T getContextualInstance(final String factoryName, final Class[] typeArgs, final Annotation[] qualifiers) { - return getContext(factoryName) - .withContextualInstanceSupport() - .orElseThrow(() -> new RuntimeException("The scope, " + getClass().getSimpleName() + ", does not support contextual instances.")) - .getContextualInstance(factoryName, typeArgs, qualifiers); - } - - private Context getContext(final String factoryName) { - final Context context = contextsByFactoryName.get(factoryName); - if (context == null) { - throw new RuntimeException("Could not find a context for the factory " + factoryName); - } else { - return context; - } - } - - @SuppressWarnings("unchecked") - @Override - public T getEagerInstance(final String factoryName) { - final T instance = getContext(factoryName).getInstance(factoryName); - if ((instance instanceof Proxy)) { - ((Proxy) instance).unwrap(); - } - - return instance; - } - - @Override - public T getNewInstance(final String factoryName) { - return getContext(factoryName).getNewInstance(factoryName); - } - - @Override - public Collection getAllFactoryHandles() { - final Collection allHandles = new ArrayList(); - for (final Context context : contexts) { - for (final Factory factory : context.getAllFactories()) { - allHandles.add(factory.getHandle()); - } - } - - return allHandles; - } - - @Override - public void destroy(final Object instance) { - for (final Context context : contexts) { - context.destroyInstance(instance); - } - } - - @Override - public boolean isManaged(final Object ref) { - for (final Context context : contexts) { - if (context.isManaged(ref)) { - return true; - } - } - - return false; - } - - @Override - public boolean addDestructionCallback(final Object instance, final DestructionCallback callback) { - boolean success = false; - for (final Context context : contexts) { - success = success || context.addDestructionCallback(instance, callback); - } - - return success; - } - - @Override - public

P getInstanceProperty(final Object instance, final String propertyName, final Class

type) { - for (final Context context : contexts) { - if (context.isManaged(instance)) { - return context.getInstanceProperty(instance, propertyName, type); - } - } - - throw new RuntimeException("The given instance, " + instance + ", is not managed."); - } - - @Override - public void finishInit() { - for (final Context context : contexts) { - for (final Factory factory : context.getAllFactories()) { - factory.init(context); - } - } - } - - @Override - public void addFactory(final Factory factory) { - final Context context = getContextForScope(factory.getHandle().getScope()); - context.registerFactory(factory); - contextsByFactoryName.put(factory.getHandle().getFactoryName(), context); - factory.init(context); - } - - private Context getContextForScope(final Class scope) { - for (final Context context : contexts) { - if (context.handlesScope(scope)) { - return context; - } - } - - throw new RuntimeException("Could not find context for the scope " + scope.getName()); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/DependentScopeContext.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/DependentScopeContext.java deleted file mode 100644 index b7d79ea2453..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/DependentScopeContext.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container; - -import java.lang.annotation.Annotation; -import java.util.Optional; - -import javax.enterprise.context.Dependent; - -import org.jboss.errai.ioc.client.api.ScopeContext; - -import static org.jboss.errai.ioc.client.container.Factory.maybeUnwrapProxy; - -/** - * The {@link Context} implementation for all {@link Dependent} scoped beans. - * Unlike other scopes, beans which have no explicit scope will be considered - * dependent. Therefore some beans will be registered with this scope that do - * not actually have the {@link Dependent} annotation. - * - * @author Max Barkley - */ -@ScopeContext({Dependent.class}) -public class DependentScopeContext extends AbstractContext implements HasContextualInstanceSupport { - - @Override - public Class getScope() { - return Dependent.class; - } - - @Override - public boolean isActive() { - return true; - } - - @Override - public boolean handlesScope(final Class scope) { - return Dependent.class.equals(scope); - } - - @Override - protected T getActiveInstance(final String factoryName) { - return null; - } - - @Override - protected boolean hasActiveInstance(final String factoryName) { - return false; - } - - @Override - protected boolean isCurrentlyCreatingActiveInstance(final String factoryName) { - /** - * Even if a factory of a dependent-scoped bean is creating an instance, that instance is never re-used so we return - * false here. - */ - return false; - } - - @Override - public Optional withContextualInstanceSupport() { - return Optional.ofNullable(this); - } - - @Override - public T getContextualInstance(final String factoryName, final Class[] typeArgs, final Annotation[] qualifiers) { - final Factory factory = this.getFactory(factoryName); - final T instance = factory.createContextualInstance(getContextManager(), typeArgs, qualifiers); - registerInstance(maybeUnwrapProxy(instance), factory); - return instance; - } - - @Override - protected void afterDestroyInstance(final Object instance) { - if (instance instanceof Proxy) removeProxy(instance); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/DestructionCallback.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/DestructionCallback.java deleted file mode 100644 index 55001df1e23..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/DestructionCallback.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container; - -/** - * A destruction callback is used to implement a set of tasks to be performed on a bean prior to it being destroyed - * (or taken out of service) by the bean manager. This interface is not designed to be directly used. Its - * implementations are usually provided by Errai's code generators and are used to orchestrate tasks such as - * {@link javax.annotation.PreDestroy} for beans. It is also used to implement implicit garbage collection tasks, - * such as the de-registering of listeners and resources associated with the bean. - * - * @author Mike Brock - */ -public interface DestructionCallback { - /** - * Called to perform the destruction task against the specified bean. - * @param t the bean instance. - */ - public void destroy(T bean); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/DynamicAnnotation.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/DynamicAnnotation.java deleted file mode 100644 index 104145e05c5..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/DynamicAnnotation.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.jboss.errai.ioc.client.container; - -import java.lang.annotation.Annotation; -import java.util.Map; - -/** - * A representation of an {@link Annotation} that was not present at - * compile-time of this script. - * - * @author Max Barkley - * @author Christian Sadilek - */ -public interface DynamicAnnotation extends Annotation { - - static DynamicAnnotation create(final String serialized) { - return DynamicAnnotationImpl.create(serialized); - } - - /** - * Returns the fully qualified name of the annotation. - * - * @return fqcn of annotation, never null. - */ - String getName(); - - /** - * Returns a map of member names to values for this annotation instance. - * - * @return map of members if present, otherwise an empty map. - */ - Map getMembers(); - - /** - * Returns the annotation member with the given name. - * - * @param name of the member, must not be null. - * @return String representation of the member value, null if member doesn't exist. - */ - default String getMember(final String name) { - return getMembers().get(name); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/DynamicAnnotationImpl.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/DynamicAnnotationImpl.java deleted file mode 100644 index c3731942f2c..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/DynamicAnnotationImpl.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container; - -import java.lang.annotation.Annotation; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -/** - * @author Max Barkley - */ -class DynamicAnnotationImpl implements DynamicAnnotation { - - static DynamicAnnotation create(final String serialized) { - final int openParenIndex = serialized.indexOf('('); - final String fqcn; - final Map members; - if (openParenIndex > -1) { - fqcn = serialized.substring(0, openParenIndex); - members = new HashMap<>(); - - final String[] rawPairs = serialized.substring(openParenIndex+1, serialized.length()-1).split(","); - for (final String rawPair : rawPairs) { - final String[] splitPair = rawPair.split("="); - members.put(splitPair[0], splitPair[1]); - } - } - else { - fqcn = serialized; - members = Collections.emptyMap(); - } - - return new DynamicAnnotationImpl(fqcn, members); - } - - private final String fqcn; - private final Map members; - - private DynamicAnnotationImpl(final String fqcn, final Map members) { - this.fqcn = fqcn; - this.members = Collections.unmodifiableMap(members); - } - - @Override - public Class annotationType() { - return DynamicAnnotation.class; - } - - @Override - public String getName() { - return fqcn; - } - - @Override - public Map getMembers() { - return members; - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/ErraiUncaughtExceptionHandler.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/ErraiUncaughtExceptionHandler.java deleted file mode 100644 index d015a3ca51e..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/ErraiUncaughtExceptionHandler.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.function.Consumer; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.core.client.GWT.UncaughtExceptionHandler; - -/** - *

- * An {@link UncaughtExceptionHandler} implementation used to dispatch to - * {@link org.jboss.errai.ioc.client.api.UncaughtExceptionHandler @UncaughtExceptionHandler}.methods. - * - *

- * Before the Errai IOC container starts, an {@link ErraiUncaughtExceptionHandler} is set as the global exception - * handler with {@link GWT#setUncaughtExceptionHandler(UncaughtExceptionHandler)}. - * - * @author Max Barkley - */ -public class ErraiUncaughtExceptionHandler implements UncaughtExceptionHandler { - - private final Optional oReplaced; - private final List> userHandlers = new ArrayList<>(); - - public ErraiUncaughtExceptionHandler(final UncaughtExceptionHandler replaced) { - oReplaced = Optional.ofNullable(replaced); - } - - @Override - public void onUncaughtException(final Throwable e) { - userHandlers.forEach(h -> h.accept(e)); - oReplaced.ifPresent(h -> h.onUncaughtException(e)); - } - - public Runnable addHandler(final Consumer handler) { - userHandlers.add(handler); - return () -> userHandlers.remove(handler); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/Factory.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/Factory.java deleted file mode 100644 index 0c79ca81da3..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/Factory.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container; - -import java.lang.annotation.Annotation; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.IdentityHashMap; -import java.util.Map; -import java.util.Set; - -import javax.enterprise.context.Dependent; - -import com.google.common.base.Supplier; -import com.google.common.collect.Multimaps; -import com.google.common.collect.SetMultimap; -import org.jboss.errai.ioc.client.api.ContextualTypeProvider; - -/** - * Creates proxies and wires dependencies for a bean. The abstract methods in - * this class are implemented by code generation. Because of this, care should - * be taken when modifying the names of fields or parameters in this type. - * - * @param - * The type of the bean that this factory creates. - * - * @author Max Barkley - */ -public abstract class Factory { - - /* - * Do not remove! Used in generated code. - */ - protected final Factory thisInstance = this; - - /* - * Do not remove! Used in generated code. - */ - protected final FactoryHandleImpl handle; - - - private final Map> referenceMaps = new IdentityHashMap<>(); - private final SetMultimap dependentScopedDependencies = Multimaps - .newSetMultimap(new IdentityHashMap>(), new Supplier>() { - @Override - public Set get() { - return Collections.newSetFromMap(new IdentityHashMap()); - } - }); - - private T incompleteInstance; - - protected Factory() { - this.handle = null; - } - - protected Factory(final FactoryHandleImpl handle) { - this.handle = handle; - } - - /** - * At runtime the init method is called once after all factories and - * {@link Context contexts} have been registered. This allows decorators an - * opportunity to register a bean type for services that may lookup instances - * on demand. - * - * @param context - * Some decorators may wish to register callbacks that create an - * instance of the bean. This should be done using - * {@link Context#getInstance(String)}. - */ - public void init(final Context context) {} - - /** - * This method is invoked whenever an actual instance of a bean must be - * constructed. If a bean is proxied, this will likely happen on the first - * invocation of a method on the proxy. Otherwise this will occur when the - * bean is injected into another type. - * - * This method always returns an unproxied, fully wired instance of a type. - * - * @param contextManager - * For requesting instances from other factories. Never {@code null}. - * @return A fully wired, unproxied instance of a bean. - */ - public T createInstance(final ContextManager contextManager) { - throw new UnsupportedOperationException("The factory, " + getClass().getSimpleName() + ", only supports contextual instances."); - } - - /** - * Like {@link #createInstance(ContextManager)} but with contextual paramters for factories backed by a - * {@link ContextualTypeProvider}. - */ - public T createContextualInstance(final ContextManager contextManager, final Class[] typeArgs, final Annotation[] qualifiers) { - throw new UnsupportedOperationException("The factory, " + getClass().getSimpleName() + ", does not support contextual instances."); - } - - public void invokePostConstructs(final T instance) {} - - public void setReference(final T instance, final String referenceName, final Object ref) { - final Map instanceRefMap = getInstanceRefMap(instance); - instanceRefMap.put(referenceName, ref); - } - - private Map getInstanceRefMap(final T instance) { - Map map = referenceMaps.get(maybeUnwrapProxy(instance)); - if (map == null) { - map = new HashMap<>(); - referenceMaps.put(instance, map); - } - - return map; - } - - @SuppressWarnings("unchecked") - public

P getReferenceAs(final T instance, final String referenceName, final Class

type) { - return (P) getInstanceRefMap(maybeUnwrapProxy(instance)).get(referenceName); - } - - public Proxy createProxy(final Context context) { - return null; - } - - public FactoryHandle getHandle() { - return handle; - } - - protected D registerDependentScopedReference(final T instance, final D dependentScopedBeanRef) { - dependentScopedDependencies.put(maybeUnwrapProxy(instance), dependentScopedBeanRef); - - return dependentScopedBeanRef; - } - - /** - * This method performs any cleanup required for destroying a type. It will - * invoke generated statements from decorators, invoke disposers or predestroy - * methods, and destroy and {@link Dependent} scoped dependencies. - * - * @param instance The instance being destroyed. - * @param contextManager For destroying dependencies. - */ - @SuppressWarnings("unchecked") - public void destroyInstance(final Object instance, final ContextManager contextManager) { - final Object unwrapped = maybeUnwrapProxy(instance); - generatedDestroyInstance(unwrapped, contextManager); - referenceMaps.remove(unwrapped); - for (final Object depRef : dependentScopedDependencies.get((T) unwrapped)) { - contextManager.destroy(depRef); - } - dependentScopedDependencies.removeAll(instance); - } - - protected void generatedDestroyInstance(final Object instance, final ContextManager contextManager) {} - - @SuppressWarnings("unchecked") - public static

P maybeUnwrapProxy(final P instance) { - if (instance instanceof Proxy) { - return (P) ((Proxy

) instance).unwrap(); - } - else { - return instance; - } - } - - public T getIncompleteInstance() { - return incompleteInstance; - } - - protected void setIncompleteInstance(final T instance) { - incompleteInstance = instance; - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/FactoryHandle.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/FactoryHandle.java deleted file mode 100644 index b79f81c1ce2..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/FactoryHandle.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container; - -import java.lang.annotation.Annotation; -import java.util.Collection; - -import javax.enterprise.context.Dependent; -import javax.inject.Named; -import javax.inject.Qualifier; - -import org.jboss.errai.ioc.client.api.ActivatedBy; - -/** - * Contains all metadata for the bean produced by a {@link Factory}. - * - * @see Factory - * @author Max Barkley - */ -public interface FactoryHandle { - - /** - * @return The set of {@link Qualifier} annotations for this factory's bean. - */ - Collection getQualifiers(); - - /** - * @return The set of all types that this factory's bean can be assigned to. - */ - Collection> getAssignableTypes(); - - /** - * @return This will be the literal class of a type that was type-injectable. If the factory was for a producer - * method, this will be the return type. If the factory was for a producer field, this will be for the field - * type. For a bean where the specific implementation type is unknown (such as for JsType) this will return - * the type that was looked up. - */ - Class getActualType(); - - /** - * @return The unique name of this factory, used for getting bean instances from {@link ContextManager#getInstance(String)}. - */ - String getFactoryName(); - - /** - * @return The scope annotation for this type. For pseudo-depdent beans, {@link Dependent} is returned. - */ - Class getScope(); - - /** - * @return True iff this bean should be initialized immediately after boostrapping completes, rather than lazily on-demand. - */ - boolean isEager(); - - /** - * @return An implementation type if the factory's bean was annotated with {@link ActivatedBy}. Otherwise {@code null}. - */ - Class getBeanActivatorType(); - - /** - * @return The name of the factory's bean, if it was annotated with {@link Named}. - */ - String getBeanName(); - - /** - * @return True iff this factory's bean is available for lookup through the bean manager. - */ - boolean isAvailableByLookup(); - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/FactoryHandleImpl.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/FactoryHandleImpl.java deleted file mode 100644 index 6be82750795..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/FactoryHandleImpl.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container; - -import java.lang.annotation.Annotation; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import org.jboss.errai.ioc.client.QualifierUtil; - -/** - * @see FactoryHandle - * @author Max Barkley - */ -public class FactoryHandleImpl implements FactoryHandle { - - private static final List defaultQualifiers = Arrays.asList(QualifierUtil.DEFAULT_QUALIFIERS); - - private List qualifiers; - private List> assignableTypes; - private final Class actualType; - private final String factoryName; - private final Class scope; - private final boolean eager; - private final String beanName; - private final Class activatorType; - private final boolean availableByLookup; - - public FactoryHandleImpl(final Class actualType, final String factoryName, final Class scope, - final boolean eager, final String beanName, final boolean availableByLookup, final Class activatorType) { - this.actualType = actualType; - this.factoryName = factoryName; - this.scope = scope; - this.eager = eager; - this.beanName = beanName; - this.activatorType = activatorType; - this.availableByLookup = availableByLookup; - } - - public FactoryHandleImpl(final Class actualType, final String factoryName, final Class scope, final boolean eager, final String beanName, final boolean availableByLookup ) { - this(actualType, factoryName, scope, eager, beanName, availableByLookup, null); - } - - @Override - public String getBeanName() { - return beanName; - } - - @Override - public Collection getQualifiers() { - if (qualifiers == null) { - return Collections.unmodifiableCollection(defaultQualifiers); - } - else { - return Collections.unmodifiableCollection(qualifiers); - } - } - - public void setQualifiers(final Annotation[] qualifiers) { - this.qualifiers = Arrays.asList(qualifiers); - } - - public void setAssignableTypes(final Class[] assignableTypes) { - this.assignableTypes = Arrays.asList(assignableTypes); - } - - @Override - public Collection> getAssignableTypes() { - return Collections.unmodifiableCollection(assignableTypes); - } - - @Override - public Class getActualType() { - return actualType; - } - - @Override - public String getFactoryName() { - return factoryName; - } - - @Override - public Class getScope() { - return scope; - } - - @Override - public String toString() { - return "[type=" + actualType + ", name=" + factoryName + ", scope=" + scope.getSimpleName() + ", qualifiers=" + qualifiers + "]"; - } - - @Override - public boolean isEager() { - return eager; - } - - @Override - public Class getBeanActivatorType() { - return activatorType; - } - - @Override - public boolean isAvailableByLookup() { - return availableByLookup; - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/HasContextualInstanceSupport.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/HasContextualInstanceSupport.java deleted file mode 100644 index 421e668aa7d..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/HasContextualInstanceSupport.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container; - -import java.lang.annotation.Annotation; - -/** - * A {@link Context} that supports creating of contextual instances. - * - * @author Max Barkley - */ -public interface HasContextualInstanceSupport extends Context { - - /** - * Create a contextual bean instance. - * - * @param factoryName - * The {@link FactoryHandle#getFactoryName() name} of the for the - * desired bean instance. - * @param typeArgs - * An array of type arguments from the injection site. - * @param qualifiers - * An array of qualifiers from the injection site. - * @return An instance of a bean from the {@link Factory} with the given - * {@link FactoryHandle#getFactoryName() name}. This instance may or - * may not be {@link Proxy proxied}. - */ - T getContextualInstance(String factoryName, Class[] typeArgs, Annotation[] qualifiers); - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/IOC.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/IOC.java deleted file mode 100644 index 75dd5528377..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/IOC.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container; - -import com.google.gwt.core.client.GWT; -import org.jboss.errai.common.client.util.CreationalCallback; -import org.jboss.errai.ioc.client.container.async.AsyncBeanManager; -import org.jboss.errai.ioc.client.container.async.AsyncBeanManagerImpl; -import org.jboss.errai.ioc.client.lifecycle.api.LifecycleEvent; -import org.jboss.errai.ioc.client.lifecycle.api.LifecycleListener; -import org.jboss.errai.ioc.client.lifecycle.api.LifecycleListenerGenerator; -import org.jboss.errai.ioc.client.lifecycle.api.LifecycleListenerRegistrar; - -/** - * A simple utility class which provides a static reference in the client to the - * bean manager. - * - * @author Mike Brock - */ -public final class IOC { - private static final IOC inst = new IOC(); - private final ClientBeanManager beanManager; - - private IOC() { - IOCEnvironment iocEnvironment; - - try { - iocEnvironment = GWT.create(IOCEnvironment.class); - } - catch (UnsupportedOperationException e) { - iocEnvironment = new IOCEnvironment() { - @Override - public boolean isAsync() { - return false; - } - - @Override - public ClientBeanManager getNewBeanManager() { - if (!GWT.isClient()) { - return new SyncBeanManagerImpl(); - } - else { - return null; - } - } - }; - } - - beanManager = iocEnvironment.getNewBeanManager(); - } - - /** - * Returns a reference to the bean manager in the client. - * - * @return the singleton instance of the client bean manager. - * - * @see SyncBeanManagerImpl - */ - public static SyncBeanManager getBeanManager() { - if (inst.beanManager instanceof AsyncBeanManager) { - return ((AsyncBeanManagerImpl) inst.beanManager).getInnerBeanManager(); - } - return (SyncBeanManagerImpl) inst.beanManager; - } - - public static AsyncBeanManager getAsyncBeanManager() { - if (inst.beanManager instanceof SyncBeanManager) { - return new SyncToAsyncBeanManagerAdapter((SyncBeanManager) inst.beanManager); - } - - return (AsyncBeanManager) inst.beanManager; - } - - /** - * Register a {@link LifecycleListenerGenerator} for - * {@linkplain LifecycleEvent IOC Lifecycle Events}. - * - * @param beanType - * The type of bean for which {@link LifecycleListener - * LifecycleListeners} created by this generator observe. - * @param listenerGenerator - * A generator creating {@link LifecycleListener LifecycleListeners} - * which observe events from the specified bean type. - */ - public static void registerLifecycleListener(final Class beanType, - final LifecycleListenerGenerator listenerGenerator) { - - getAsyncBeanManager().lookupBean(LifecycleListenerRegistrar.class).getInstance( - new CreationalCallback() { - - @Override - public void callback(final LifecycleListenerRegistrar registrar) { - registrar.registerGenerator(beanType, listenerGenerator); - } - }); - } - - /** - * Register a single {@link LifecycleListener} for {@link LifecycleEvent - * LifecycleEvents} from a single instance. - * - * @param instance The instance to be observed. - * @param listener The listener to be registered. - */ - public static void registerLifecycleListener(final T instance, final LifecycleListener listener) { - getAsyncBeanManager().lookupBean(LifecycleListenerRegistrar.class).getInstance( - new CreationalCallback() { - - @Override - public void callback(final LifecycleListenerRegistrar registrar) { - registrar.registerListener(instance, listener); - } - }); - } - - /** - * Unregister a {@link LifecycleListenerGenerator} and all the - * {@link LifecycleListener LifecycleListeners} created by this generator. - * - * @param beanType - * The bean type for which this generator created listeners. - * @param generator - * The generator to be unregistered (must be the same instance as was - * registered). - */ - public static void unregisterLifecycleListener(final Class beanType, - final LifecycleListenerGenerator generator) { - getAsyncBeanManager().lookupBean(LifecycleListenerRegistrar.class).getInstance( - new CreationalCallback() { - - @Override - public void callback(final LifecycleListenerRegistrar registrar) { - registrar.unregisterGenerator(beanType, generator); - } - }); - } - - /** - * Unregister a single {@link LifecycleListener} for {@link LifecycleEvent - * LifecycleEvents} from a single instance. - * - * @param instance The instance that was observed. - * @param listener The listener that was registered. - */ - public static void unregisterLifecycleListener(final T instance, final LifecycleListener listener) { - getAsyncBeanManager().lookupBean(LifecycleListenerRegistrar.class).getInstance( - new CreationalCallback() { - - @Override - public void callback(final LifecycleListenerRegistrar registrar) { - registrar.unregisterListener(instance, listener); - } - }); - } - - /** - * For testing only. Resets the bean manager. - */ - public static void reset() { - if (inst.beanManager instanceof SyncBeanManagerImpl) { - ((SyncBeanManagerImpl) inst.beanManager).reset(); - } else if (inst.beanManager instanceof AsyncBeanManagerImpl) { - ((AsyncBeanManagerImpl) inst.beanManager).reset(); - } else { - throw new RuntimeException("Cannot reset bean manager of type " + inst.beanManager.getClass().getName()); - } - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/IOCBeanDef.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/IOCBeanDef.java deleted file mode 100644 index 5357509eadc..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/IOCBeanDef.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container; - -import java.lang.annotation.Annotation; -import java.util.Set; - -import org.jboss.errai.ioc.client.api.ActivatedBy; - -/** - * Definition of a managed bean. - * - * @author Max Barkley - * @author Christian Sadilek - */ -public interface IOCBeanDef { - - /** - * @param type - * Must not be null. - * @return True if this bean is assginable to the given type. - */ - public boolean isAssignableTo(Class type); - - /** - * Returns the type of the bean. - * - * @see #getBeanClass() - * @return the type of the bean. - */ - public Class getType(); - - /** - * Returns the actual bean class represented by this bean. - * - * @return the actual type of the bean. - */ - public Class getBeanClass(); - - /** - * Returns the scope of the bean. - * - * @returns the annotation type representing the scope of the bean. - */ - public Class getScope(); - - /** - * Returns any qualifiers associated with the bean. - * - * @return Must never be null. - */ - public Set getQualifiers(); - - /** - * Returns true if the beans qualifiers match the specified set of qualifiers. - * - * @param annotations - * the qualifiers to compare - * @return returns whether or not the bean matches the set of qualifiers - */ - public boolean matches(Set annotations); - - /** - * Returns the name of the bean. - * - * @return the name of the bean. If the bean does not have a name, returns - * null. - */ - public String getName(); - - /** - * Returns true if the bean is activated. All managed beans are activated by - * default unless a {@link BeanActivator} was specified using - * {@link ActivatedBy} which will be consulted when invoking this method. - * - * @return true if activated, otherwise false. - */ - public boolean isActivated(); - - /** - * Returns true if this bean definition was discovered and loaded at runtime from - * an external script. - * - * @return true if dynamic, otherwise false. - */ - public default boolean isDynamic() { - return false; - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/IOCEnvironment.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/IOCEnvironment.java deleted file mode 100644 index d29db857534..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/IOCEnvironment.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container; - -/** - * @author Mike Brock - */ -public interface IOCEnvironment { - public boolean isAsync(); - ClientBeanManager getNewBeanManager(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/IOCResolutionException.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/IOCResolutionException.java deleted file mode 100644 index 4a471c25bbd..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/IOCResolutionException.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container; - -/** - * An exception that is thrown if a bean cannot be resolved. - * - * @author Mike Brock - */ -public class IOCResolutionException extends RuntimeException { - public IOCResolutionException(final String message) { - super(message); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/InitializationCallback.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/InitializationCallback.java deleted file mode 100644 index 2ef56b0f296..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/InitializationCallback.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container; - -/** - * An initialization callback is used to implement a set of tasks to be executed against the specified bean, prior - * to putting the bean into service. This interface is not designed to be directly used. Its implementations are - * usually provided by Errai's code generators and are used to orchestrate tasks such as - * {@link javax.annotation.PostConstruct} for beans. - * - * @author Mike Brock - */ -public interface InitializationCallback { - /** - * Called to perform the initialization task against the specified bean. - * @param t the bean instance. - */ - public void init(T instance); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/JsTypeProvider.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/JsTypeProvider.java deleted file mode 100644 index 11cc2ac31b9..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/JsTypeProvider.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container; - -import javax.inject.Named; - -import jsinterop.annotations.JsType; -import org.jboss.errai.ioc.client.JsArray; - -/** - * Contract for providing managed beans across different scripts. - * Implementations of this interface are code-generated by Errai IOC. - * - * @author Christian Sadilek - * @author Max Barkley - */ -@JsType -public interface JsTypeProvider { - - /** - * Returns a managed bean instance. - */ - T getInstance(); - - /** - * Returns the name specified by {@link Named} or else null. - */ - String getName(); - - /** - * Returns the name of the {@link Factory} that generates this bean, or else null. - */ - String getFactoryName(); - - /** - * Returns string representations of the qualifiers and their members. - */ - JsArray getQualifiers(); - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/Proxy.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/Proxy.java deleted file mode 100644 index cf92bab77c5..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/Proxy.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container; - - -/** - * Normal scoped beans or dependent scoped beans decorated with AOP features - * will be wrapped in proxies. All proxies produced by a {@link Factory} must - * implement this interface. - * - * @param The type of the instance being proxied. - * - * @author Max Barkley - */ -public interface Proxy { - - /** - * @return Returns this proxy as the type of the instance it is proxying. - */ - T asBeanType(); - - /** - * Set the instance that this proxy dispatches to (i.e. set the proxied instance). - * - * @param instance An instance created by the same factory as this proxy. - */ - void setInstance(T instance); - - /** - * Removes the reference to any instance that was previously proxied (via {@link #setInstance(Object)}). - */ - void clearInstance(); - - /** - * This is called after a proxy is created so that the proxy can request a proxied instance on demand. - * - * @param context The context associated with the {@link Factory} that created this proxy. - */ - void setProxyContext( Context context ); - - /** - * @return The context set by {@link #setProxyContext(Context)}. - */ - Context getProxyContext(); - - /** - * Called once after {@link #setInstance(Object)} is called. - * - * @param instance The instance wrapped by this proxy. - */ - void initProxyProperties(final T instance); - - /** Migrated from deleted WrappedPortal - * - * @return The wrapped object - */ - Object unwrap(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/ProxyHelper.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/ProxyHelper.java deleted file mode 100644 index ef93ed19a71..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/ProxyHelper.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container; - -/** - * For any {@link Proxy}, all proxied methods should dispatch to the instance - * returned by {@link #getInstance(Proxy)}. It is the helpers job to load - * an instance for the proxy on demand. - * - * @param - * The type wrapped by the proxy containing this helper. - * - * @author Max Barkley - */ -public interface ProxyHelper { - - /** - * @param instance The instance to be returened by future calls to {@link #getInstance(Proxy)}. - */ - void setInstance(T instance); - - /** - * @param proxy The proxy containing this helper. - * @return The instance that the containing proxy should dispatch to. - */ - T getInstance(Proxy proxy); - - /** - * Removes the stored proxied reference so that future calls to - * {@link #getInstance(Proxy)} will need to load a new instance. - */ - void clearInstance(); - - /** - * Required for loading instances on demand. - * - * @param context The context associated with the containing {@link Proxy}. - */ - void setProxyContext( Context context ); - - /** - * @return The {@link Context} previously set by {@link #setProxyContext(Context)}. - */ - Context getProxyContext(); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/ProxyHelperImpl.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/ProxyHelperImpl.java deleted file mode 100644 index 98c30d42f87..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/ProxyHelperImpl.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container; - -/** - * @see ProxyHelper - * @author Max Barkley - */ -public class ProxyHelperImpl implements ProxyHelper { - - private final String factoryName; - - private Context context; - private T instance; - - public ProxyHelperImpl(final String factoryName) { - this.factoryName = factoryName; - } - - @Override - public void setInstance(final T instance) { - this.instance = instance; - } - - @Override - public T getInstance(final Proxy proxy) { - if (instance == null) { - trySettingInstance(); - proxy.initProxyProperties(instance); - } - - return instance; - } - - private void trySettingInstance() { - assertContextIsSet(); - - if (context.isActive()) { - instance = context.getActiveNonProxiedInstance(factoryName); - } else { - throw new RuntimeException("Cannot access a bean from the inactive " + context.getScope().getSimpleName() + " context."); - } - } - - @Override - public void clearInstance() { - instance = null; - } - - @Override - public void setProxyContext( final Context context ) { - if (this.context != null) { - throw new RuntimeException("Context can only be set once."); - } - - this.context = context; - } - - @Override - public Context getProxyContext() { - assertContextIsSet(); - - return context; - } - - private void assertContextIsSet() { - if (context == null) { - throw new RuntimeException("Context has not yet been set."); - } - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/RefHolder.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/RefHolder.java deleted file mode 100644 index 55ee8b3a8ce..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/RefHolder.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container; - -/** - * @author Mike Brock - */ -public final class RefHolder { - private T ref; - - public T get() { - return ref; - } - - public void set(T ref) { - this.ref = ref; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/SyncBeanDef.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/SyncBeanDef.java deleted file mode 100644 index caf22c25d93..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/SyncBeanDef.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container; - -/** - * Represents a bean definition within the bean manager. - * - * @author Max Barkley - */ -public interface SyncBeanDef extends IOCBeanDef { - - /** - * Returns an instance of the bean within the active scope. - * - * @return The bean instance. - */ - public T getInstance(); - - /** - * Returns a new instance of the bean. Calling this method overrides the underlying scope and - * instantiates a new instance of the bean. - * - * @return a new instance of the bean. - */ - public T newInstance(); - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/SyncBeanManager.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/SyncBeanManager.java deleted file mode 100644 index f7d91118846..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/SyncBeanManager.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container; - -import java.lang.annotation.Annotation; -import java.util.Collection; - -/** - * Contract for injectable client-side instances for run-time bean management in - * synchronous IOC mode. - * - * @author Mike Brock - * @author Max Barkley - * @author Christian Sadilek - */ -public interface SyncBeanManager extends ClientBeanManager { - - /** - * Register a bean with the bean manager. The registered bean will be - * available for lookup, by type and by name if applicable. - * - * @param beanDef - * The bean def to register. - */ - void registerBean(SyncBeanDef beanDef); - - /** - * Register a bean with the bean manager as being assignable to another type. - * - * @param beanDef - * The bean def to be registered. - * @param type - * The type by which this beanDef will be available for lookup. - */ - void registerBeanTypeAlias(SyncBeanDef beanDef, final Class type); - - /** - * Looks up all beans by name. The name is either the fully qualified type - * name of an assignable type or a given name as specified by - * {@link javax.inject.Named}. - * - * @param name - * the fqcn of an assignable type, or a given name specified by - * {@link javax.inject.Named}, must not be null. - * - * @return and unmodifiable list of all beans with the specified name. - */ - @SuppressWarnings("rawtypes") - Collection lookupBeans(String name); - - /** - * Looks up all beans of the specified type. - * - * @param type - * The type of the bean - * - * @return An unmodifiable list of all the beans that match the specified - * type. Returns an empty list if there is no matching type. - */ - Collection> lookupBeans(Class type); - - /** - * Looks up a bean reference based on type and qualifiers. Returns - * null if there is no type associated with the specified - * - * @param type - * The type of the bean - * @param qualifiers - * qualifiers to match - * - * @return An unmodifiable list of all beans which match the specified type - * and qualifiers. Returns an empty list if no beans match. - */ - Collection> lookupBeans(Class type, Annotation... qualifiers); - - /** - * Looks up a bean reference based on type and qualifiers. Returns - * null if there is no type associated with the specified - * - * @param type - * The type of the bean - * @param qualifiers - * qualifiers to match - * @param - * The type of the bean - * - * @return An instance of the {@link IOCSingletonBean} for the matching type - * and qualifiers. Throws an {@link IOCResolutionException} if there - * is a matching type but none of the qualifiers match or if more than - * one bean matches. - */ - SyncBeanDef lookupBean(Class type, Annotation... qualifiers); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/SyncBeanManagerImpl.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/SyncBeanManagerImpl.java deleted file mode 100644 index 9d5d457b2ed..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/SyncBeanManagerImpl.java +++ /dev/null @@ -1,448 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container; - -import java.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -import javax.enterprise.context.Dependent; -import javax.enterprise.inject.Alternative; - -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.Multimap; -import org.jboss.errai.common.client.api.Assert; -import org.jboss.errai.ioc.client.JsArray; -import org.jboss.errai.ioc.client.QualifierUtil; -import org.jboss.errai.ioc.client.WindowInjectionContext; -import org.jboss.errai.ioc.client.WindowInjectionContextStorage; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A simple bean manager provided by the Errai IOC framework. The manager provides access to all of the wired beans - * and their instances. Since the actual wiring code is generated, the bean manager is populated by the generated - * code at bootstrap time. - * - * @author Max Barkley - * @author Mike Brock - * @author Christian Sadilek - */ -@Alternative -public class SyncBeanManagerImpl implements SyncBeanManager, BeanManagerSetup { - - private static final Logger logger = LoggerFactory.getLogger(SyncBeanManager.class); - - private ContextManager contextManager; - private final Multimap handlesByName = ArrayListMultimap.create(); - private final Multimap> runtimeBeanDefsByName = ArrayListMultimap.create(); - - @Override - public void destroyBean(final Object ref) { - contextManager.destroy(ref); - } - - @Override - public boolean isManaged(final Object ref) { - return contextManager.isManaged(ref); - } - - @Override - public Object getActualBeanReference(final Object ref) { - return Factory.maybeUnwrapProxy(ref); - } - - @Override - public boolean isProxyReference(final Object ref) { - return ref instanceof Proxy; - } - - @Override - public boolean addDestructionCallback(final Object beanInstance, final DestructionCallback destructionCallback) { - return contextManager.addDestructionCallback(beanInstance, destructionCallback); - } - - @Override - public void setContextManager(final ContextManager contextManager) { - if (this.contextManager != null) { - throw new RuntimeException("The ContextManager must only be set once."); - } - this.contextManager = contextManager; - init(); - } - - private void init() { - final Collection eager = addFactories(); - initializeEagerBeans(eager); - } - - private void initializeEagerBeans(final Collection eager) { - logger.debug("Initializing eager beans..."); - final long start = System.currentTimeMillis(); - if (logger.isTraceEnabled()) { - for (final FactoryHandle handle : eager) { - logger.trace("Initializing {}...", handle); - final long beanStart = System.currentTimeMillis(); - contextManager.getEagerInstance(handle.getFactoryName()); - final long duration = System.currentTimeMillis() - beanStart; - logger.trace("Finished initializing in {}ms.", duration); - } - } - else { - for (final FactoryHandle handle : eager) { - contextManager.getEagerInstance(handle.getFactoryName()); - } - } - final long duration = System.currentTimeMillis() - start; - logger.debug("Initialized {} eager beans in {}ms.", eager.size(), duration); - } - - private Collection addFactories() { - final Collection eager = new ArrayList<>(); - logger.debug("Adding factories..."); - final long start = System.currentTimeMillis(); - final Collection allFactoryHandles = contextManager.getAllFactoryHandles(); - - for (final FactoryHandle handle : allFactoryHandles) { - if (handle.isEager()) { - eager.add(handle); - } - addFactory(handle); - } - - final long duration = System.currentTimeMillis() - start; - logger.debug("Added {} factories in {}ms.", allFactoryHandles.size(), duration); - - return eager; - } - - private void addFactory(final FactoryHandle handle) { - for (final Class assignableType : handle.getAssignableTypes()) { - handlesByName.put(assignableType.getName(), handle); - } - if (handle.getBeanName() != null) { - handlesByName.put(handle.getBeanName(), handle); - } - } - - @SuppressWarnings({ "rawtypes" }) - @Override - public Collection lookupBeans(final String name) { - return lookupBeans(name, false); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - public Collection lookupBeans(final String name, final boolean keepJsDups) { - Assert.notNull(name); - logger.debug("Looking up beans for {}", name); - - final Collection handles = handlesByName.get(name); - final Collection> runtimeBeanDefs = runtimeBeanDefsByName.get(name); - final JsArray> jsProviders = getJsProviders(name); - - final Set beanDefFactoryNames = new HashSet<>(); - final Collection beanDefs = new ArrayList>(handles.size()+runtimeBeanDefs.size()+jsProviders.length()); - beanDefs.addAll(runtimeBeanDefs); - for (final FactoryHandle handle : handles) { - if (handle.isAvailableByLookup()) { - beanDefs.add(new IOCBeanDefImplementation<>(handle, this.getType(name, handle, handle.getActualType()))); - beanDefFactoryNames.add(handle.getFactoryName()); - } - } - for (final JsTypeProvider provider : JsArray.iterable(jsProviders)) { - logger.debug("Found JS provider for name {} from factory {}", provider.getName(), provider.getFactoryName()); - if (keepJsDups || provider.getFactoryName() == null || !beanDefFactoryNames.contains(provider.getFactoryName())) { - logger.debug("Keeping JS provider for name {} from factory {}", provider.getName(), provider.getFactoryName()); - beanDefs.add(new JsTypeBeanDefImplementation(provider, name)); - } - else { - logger.debug("Rejecting duplicate JS provider for name {} from factory {}", provider.getName(), provider.getFactoryName()); - } - } - - logger.debug("Looked up {} beans: {}", beanDefs.size(), beanDefs); - - return beanDefs; - } - - private JsArray> getJsProviders(final String name) { - final WindowInjectionContext windowInjectionContext = WindowInjectionContextStorage.createOrGet(); - - // This check may be false if -generateJsInteropExports is not set - if (hasGetProvidersMethod(windowInjectionContext)) { - return windowInjectionContext.getProviders(name); - } - else { - logger.debug("Did not look up external JsTypeProviders for {}. " - + "Hint: It looks like the WindowInjectionContext was supplied by an app " - + "that was compiled without the flag \"-generateJsInteropExports\".", name); - return new JsArray<>(new JsTypeProvider[0]); - } - } - - private static native boolean hasGetProvidersMethod(WindowInjectionContext obj)/*-{ - return obj.getProviders != undefined; - }-*/; - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public Collection> lookupBeans(final Class type) { - return (Collection) lookupBeans(type.getName()); - } - - @SuppressWarnings("unchecked") - private Class getType(final String typeName, final FactoryHandle handle, final Class defaultType) { - for (final Class type : handle.getAssignableTypes()) { - if (type.getName().equals(typeName)) { - return (Class) type; - } - } - - return (Class) defaultType; - } - - @Override - public Collection> lookupBeans(final Class type, final Annotation... qualifiers) { - final Set qualifierSet = new HashSet<>(Arrays.asList(qualifiers)); - final Collection> candidates = lookupBeans(type); - final Iterator> iter = candidates.iterator(); - while (iter.hasNext()) { - final SyncBeanDef beanDef = iter.next(); - if (!beanDef.matches(qualifierSet)) { - iter.remove(); - } - } - - return candidates; - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - public SyncBeanDef lookupBean(final Class type, Annotation... qualifiers) { - if (qualifiers.length == 0) { - qualifiers = new Annotation[] { QualifierUtil.DEFAULT_ANNOTATION }; - } - final Collection resolved = lookupBeans(type, qualifiers); - if (resolved.isEmpty()) { - throw BeanManagerUtil.unsatisfiedResolutionException(type, qualifiers); - } else if (resolved.size() > 1) { - throw BeanManagerUtil.ambiguousResolutionException(type, resolved, qualifiers); - } else { - return (SyncBeanDef) resolved.iterator().next(); - } - } - - @Override - public void registerBean(final SyncBeanDef beanDef) { - runtimeBeanDefsByName.put(beanDef.getType().getName(), beanDef); - if (!beanDef.getType().getName().equals(beanDef.getBeanClass().getName())) { - runtimeBeanDefsByName.put(beanDef.getBeanClass().getName(), beanDef); - } - if (beanDef.getName() != null) { - runtimeBeanDefsByName.put(beanDef.getName(), beanDef); - } - } - - @Override - public void registerBeanTypeAlias(final SyncBeanDef beanDef, final Class type) { - runtimeBeanDefsByName.put(type.getName(), beanDef); - } - - /** - * For testing only. - */ - public void reset() { - contextManager = null; - handlesByName.clear(); - runtimeBeanDefsByName.clear(); - } - - // TODO Find way to properly get scope, qualifiers, and assignable types. - @SuppressWarnings("rawtypes") - private final class JsTypeBeanDefImplementation implements SyncBeanDef { - private final JsTypeProvider provider; - private final String name; - - private JsTypeBeanDefImplementation(final JsTypeProvider provider, final String name) { - this.provider = provider; - this.name = name; - } - - @Override - public boolean isAssignableTo(final Class type) { - return Object.class.equals(type) || (type != null && type.getName().equals(name)); - } - - @Override - public Class getType() { - return null; - } - - @Override - public Class getBeanClass() { - return null; - } - - @Override - public Class getScope() { - return Dependent.class; - } - - @Override - public Set getQualifiers() { - final Set qualifiers = new HashSet<>(); - for (final String serializedQualifier : JsArray.iterable(provider.getQualifiers())) { - qualifiers.add(DynamicAnnotation.create(serializedQualifier)); - } - - return qualifiers; - } - - @Override - public boolean matches(final Set annotations) { - return true; - } - - @Override - public String getName() { - return provider.getName(); - } - - @Override - public boolean isActivated() { - return true; - } - - @Override - public Object getInstance() { - return provider.getInstance(); - } - - @Override - public Object newInstance() { - throw new UnsupportedOperationException("Cannot create new instance of JsType bean."); - } - - @Override - public boolean isDynamic() { - return true; - } - - @Override - public String toString() { - return "[JsTypeBeanDef: factoryName=" + provider.getFactoryName() + ", name=" + provider.getName() + "]"; - } - } - - private final class IOCBeanDefImplementation implements SyncBeanDef { - private final FactoryHandle handle; - private final Class type; - private Set qualifiers; - - private IOCBeanDefImplementation(final FactoryHandle handle, final Class type) { - this.handle = handle; - this.type = type; - } - - @Override - public String toString() { - return BeanManagerUtil.beanDeftoString(handle); - } - - @Override - public Class getType() { - return type; - } - - @SuppressWarnings("unchecked") - @Override - public Class getBeanClass() { - return (Class) handle.getActualType(); - } - - @Override - public Class getScope() { - return handle.getScope(); - } - - @Override - public T getInstance() { - final T instance = contextManager.getInstance(handle.getFactoryName()); - if (instance instanceof Proxy) { - @SuppressWarnings("unchecked") - final Proxy proxy = (Proxy) instance; - // Forces bean to be loaded. - proxy.unwrap(); - } - - return instance; - } - - @Override - public T newInstance() { - return contextManager.getNewInstance(handle.getFactoryName()); - } - - @Override - public Set getQualifiers() { - if (qualifiers == null) { - qualifiers = new HashSet<>(handle.getQualifiers()); - } - - return qualifiers; - } - - @Override - public boolean matches(final Set annotations) { - return QualifierUtil.matches(annotations, handle.getQualifiers()); - } - - @Override - public String getName() { - return handle.getBeanName(); - } - - @Override - public boolean isActivated() { - final Class activatorType = handle.getBeanActivatorType(); - if (activatorType == null) { - return true; - } else { - final BeanActivator activator = lookupBean(activatorType).getInstance(); - return activator.isActivated(); - } - } - - @Override - public boolean isAssignableTo(final Class type) { - return handle.getAssignableTypes().contains(type); - } - } - - public void addFactory(final Factory factory) { - contextManager.addFactory(factory); - addFactory(factory.getHandle()); - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/SyncToAsyncBeanManagerAdapter.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/SyncToAsyncBeanManagerAdapter.java deleted file mode 100644 index 24376f13849..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/SyncToAsyncBeanManagerAdapter.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container; - -import java.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import javax.enterprise.inject.Alternative; - -import org.jboss.errai.common.client.util.CreationalCallback; -import org.jboss.errai.ioc.client.container.async.AsyncBeanDef; -import org.jboss.errai.ioc.client.container.async.AsyncBeanManager; - -/** - * An adapter that makes the asynchronous bean manager API work with a synchronous bean manager. - * - * @author Christian Sadilek - */ -@Alternative -public class SyncToAsyncBeanManagerAdapter implements AsyncBeanManager { - - private final SyncBeanManager bm; - - public SyncToAsyncBeanManagerAdapter(final SyncBeanManager bm) { - this.bm = bm; - } - - @Override - public void destroyBean(final Object ref) { - bm.destroyBean(ref); - } - - @Override - public boolean isManaged(final Object ref) { - return bm.isManaged(ref); - } - - @Override - public Object getActualBeanReference(final Object ref) { - return bm.getActualBeanReference(ref); - } - - @Override - public boolean isProxyReference(final Object ref) { - return bm.isProxyReference(ref); - } - - @Override - public boolean addDestructionCallback(final Object beanInstance, final DestructionCallback destructionCallback) { - return bm.addDestructionCallback(beanInstance, destructionCallback); - } - - @Override - @SuppressWarnings("rawtypes") - public Collection lookupBeans(final String name) { - final Collection beanDefs = bm.lookupBeans(name); - - final List asyncBeanDefs = new ArrayList<>(); - for (final SyncBeanDef beanDef : beanDefs) { - asyncBeanDefs.add(createAsyncBeanDef(beanDef)); - } - - return asyncBeanDefs; - } - - @Override - public Collection> lookupBeans(final Class type) { - return lookupBeans(type, new Annotation[0]); - } - - @Override - @SuppressWarnings("unchecked") - public Collection> lookupBeans(final Class type, final Annotation... qualifiers) { - final Collection> beanDefs = bm.lookupBeans(type, qualifiers); - - final List> asyncBeanDefs = new ArrayList<>(); - for (final SyncBeanDef beanDef : beanDefs) { - asyncBeanDefs.add(createAsyncBeanDef(beanDef)); - } - - return asyncBeanDefs; - } - - @Override - @SuppressWarnings({ "unchecked" }) - public AsyncBeanDef lookupBean(final Class type, final Annotation... qualifiers) { - final SyncBeanDef beanDef = bm.lookupBean(type, qualifiers); - return createAsyncBeanDef(beanDef); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - private AsyncBeanDef createAsyncBeanDef(final SyncBeanDef beanDef) { - final AsyncBeanDef abd = new AsyncBeanDef() { - - @Override - public Class getType() { - return beanDef.getType(); - } - - @Override - public Class getBeanClass() { - return beanDef.getBeanClass(); - } - - @Override - public Class getScope() { - return beanDef.getScope(); - } - - @Override - public void getInstance(final CreationalCallback callback) { - callback.callback(beanDef.getInstance()); - } - - @Override - public void newInstance(final CreationalCallback callback) { - callback.callback(beanDef.newInstance()); - } - - @Override - public Set getQualifiers() { - return beanDef.getQualifiers(); - } - - @Override - public boolean matches(final Set annotations) { - return beanDef.matches(annotations); - } - - @Override - public String getName() { - return beanDef.getName(); - } - - @Override - public boolean isActivated() { - return beanDef.isActivated(); - } - - @Override - public boolean isAssignableTo(final Class type) { - return beanDef.isAssignableTo(type); - } - }; - - return abd; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/async/AsyncBeanDef.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/async/AsyncBeanDef.java deleted file mode 100644 index 045b22cede6..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/async/AsyncBeanDef.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container.async; - -import org.jboss.errai.common.client.util.CreationalCallback; -import org.jboss.errai.ioc.client.container.IOCBeanDef; - -/** - * @author Max Barkley - */ -public interface AsyncBeanDef extends IOCBeanDef { - - /** - * Returns an instance of the bean within the active scope. - * - * @return The bean instance. - */ - public void getInstance(CreationalCallback callback); - - /** - * Returns a new instance of the bean. Calling this method overrides the underlying scope and instantiates a new - * instance of the bean. - * - * @return a new instance of the bean. - */ - public void newInstance(CreationalCallback callback); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/async/AsyncBeanFuture.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/async/AsyncBeanFuture.java deleted file mode 100644 index 80490c2a8b4..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/async/AsyncBeanFuture.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container.async; - -import org.jboss.errai.common.client.util.CreationalCallback; - -/** - * @author Mike Brock - */ -public class AsyncBeanFuture { - private T value; - private CreationalCallback creationalCallback; - - public AsyncBeanFuture(final CreationalCallback creationalCallback) { - this.creationalCallback = new CreationalCallback() { - @Override - public void callback(final T beanInstance) { - value = beanInstance; - if (creationalCallback != null) { - creationalCallback.callback(beanInstance); - } - } - }; - } - - public T get() { - if (value == null) { - throw new AsyncBeanNotLoaded(); - } - return value; - } - - public boolean isLoaded() { - return value != null; - } - - public CreationalCallback getCreationalCallback() { - return creationalCallback; - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/async/AsyncBeanManager.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/async/AsyncBeanManager.java deleted file mode 100644 index 4c560cb39f6..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/async/AsyncBeanManager.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container.async; - -import java.lang.annotation.Annotation; -import java.util.Collection; - -import org.jboss.errai.ioc.client.container.ClientBeanManager; - -/** - * Contract for injectable client-side instances for run-time bean management in - * asynchronous IOC mode. - * - * @author Mike Brock - * @author Max Barkley - * @author Christian Sadilek - */ -public interface AsyncBeanManager extends ClientBeanManager { - - /** - * Looks up all beans by name. The name is either the fully qualified type - * name of an assignable type or a given name as specified by - * {@link javax.inject.Named}. - * - * @param name - * the fqcn of an assignable type, or a given name specified by - * {@link javax.inject.Named}, must not be null. - * - * @return and unmodifiable list of all beans with the specified name. - */ - @SuppressWarnings("rawtypes") - Collection lookupBeans(String name); - - /** - * Looks up all beans of the specified type. - * - * @param type - * The type of the bean - * - * @return An unmodifiable list of all the beans that match the specified type. Returns an empty list if there is - * no matching type. - */ - Collection> lookupBeans(Class type); - - /** - * Looks up a bean reference based on type and qualifiers. Returns null if there is no type associated - * with the specified - * - * @param type - * The type of the bean - * @param qualifiers - * qualifiers to match - * - * @return An unmodifiable list of all beans which match the specified type and qualifiers. Returns an empty list - * if no beans match. - */ - Collection> lookupBeans(Class type, Annotation... qualifiers); - - /** - * Looks up a bean reference based on type and qualifiers. Returns null if there is no type associated - * with the specified - * - * @param type - * The type of the bean - * @param qualifiers - * qualifiers to match - * @param - * The type of the bean - * - * @return An instance of the {@link org.jboss.errai.ioc.client.container.IOCSingletonBean} for the matching type and qualifiers. - * Throws an {@link org.jboss.errai.ioc.client.container.IOCResolutionException} if there is a matching type but none of the - * qualifiers match or if more than one bean matches. - */ - AsyncBeanDef lookupBean(Class type, Annotation... qualifiers); -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/async/AsyncBeanManagerImpl.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/async/AsyncBeanManagerImpl.java deleted file mode 100644 index ede228e7e5e..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/async/AsyncBeanManagerImpl.java +++ /dev/null @@ -1,456 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container.async; - -import java.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Deque; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Map; -import java.util.Queue; -import java.util.Set; - -import javax.enterprise.inject.Alternative; -import javax.inject.Provider; - -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; -import org.jboss.errai.common.client.util.CreationalCallback; -import org.jboss.errai.ioc.client.QualifierUtil; -import org.jboss.errai.ioc.client.container.BeanManagerSetup; -import org.jboss.errai.ioc.client.container.BeanManagerUtil; -import org.jboss.errai.ioc.client.container.ContextManager; -import org.jboss.errai.ioc.client.container.DestructionCallback; -import org.jboss.errai.ioc.client.container.Factory; -import org.jboss.errai.ioc.client.container.FactoryHandle; -import org.jboss.errai.ioc.client.container.RefHolder; -import org.jboss.errai.ioc.client.container.SyncBeanDef; -import org.jboss.errai.ioc.client.container.SyncBeanManager; -import org.jboss.errai.ioc.client.container.SyncBeanManagerImpl; - -/** - * @author Max Barkley - */ -@Alternative -public class AsyncBeanManagerImpl implements AsyncBeanManager, BeanManagerSetup, AsyncBeanManagerSetup { - - private final SyncBeanManagerImpl innerBeanManager = new SyncBeanManagerImpl(); - - private final Multimap typeNamesByName = HashMultimap.create(); - private final Multimap> unloadedByTypeName = HashMultimap.create(); - private final Map> unloadedByFactoryName = new HashMap<>(); - - @Override - public void destroyBean(final Object ref) { - innerBeanManager.destroyBean(ref); - } - - @Override - public boolean isManaged(final Object ref) { - return innerBeanManager.isManaged(ref); - } - - @Override - public Object getActualBeanReference(final Object ref) { - return innerBeanManager.getActualBeanReference(ref); - } - - @Override - public boolean isProxyReference(final Object ref) { - return innerBeanManager.isProxyReference(ref); - } - - @Override - public boolean addDestructionCallback(final Object beanInstance, final DestructionCallback destructionCallback) { - return innerBeanManager.addDestructionCallback(beanInstance, destructionCallback); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - public Collection lookupBeans(final String name) { - final Collection syncBeans = innerBeanManager.lookupBeans(name); - final Collection beans = wrapSyncBeans(syncBeans); - addUnloadedBeans(beans, name); - - return beans; - } - - private Collection> wrapSyncBeans(final Collection> syncBeans) { - final Collection> asyncBeans = new ArrayList<>(syncBeans.size()); - - for (final SyncBeanDef syncBean : syncBeans) { - asyncBeans.add(new SyncToAsyncBeanDef<>(syncBean)); - } - - return asyncBeans; - } - - @Override - public Collection> lookupBeans(final Class type) { - return lookupBeans(type, QualifierUtil.DEFAULT_ANNOTATION); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - public Collection> lookupBeans(final Class type, Annotation... qualifiers) { - if (qualifiers.length == 0) { - qualifiers = new Annotation[] { QualifierUtil.DEFAULT_ANNOTATION }; - } - - final Collection beans = wrapSyncBeans(innerBeanManager.lookupBeans(type, qualifiers)); - addUnloadedBeans(beans, type, type.getName(), qualifiers); - - return beans; - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - private void addUnloadedBeans(final Collection beans, final Class type, final String typeName, - final Annotation... qualifiers) { - final Collection> unloadedCandidates = unloadedByTypeName.get(typeName); - final Collection allOf = Arrays.asList(qualifiers); - for (final UnloadedFactory unloaded : unloadedCandidates) { - if (QualifierUtil.matches(allOf, unloaded.getHandle().getQualifiers())) { - final Class beanType = (Class) (type != null ? type : unloaded.getHandle().getActualType()); - beans.add(unloaded.createBeanDef(beanType)); - } - } - } - - @SuppressWarnings("rawtypes") - private void addUnloadedBeans(final Collection beans, final String name) { - for (final String typeName : typeNamesByName.get(name)) { - addUnloadedBeans(beans, null, typeName, QualifierUtil.DEFAULT_ANNOTATION); - } - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - public AsyncBeanDef lookupBean(final Class type, final Annotation... qualifiers) { - final Collection beans = lookupBeans(type, qualifiers); - - if (beans.size() > 1) { - throw BeanManagerUtil.ambiguousResolutionException(type, beans, qualifiers); - } else if (beans.isEmpty()) { - throw BeanManagerUtil.unsatisfiedResolutionException(type, qualifiers); - } else { - return (AsyncBeanDef) beans.iterator().next(); - } - } - - @Override - public void setContextManager(final ContextManager contextManager) { - innerBeanManager.setContextManager(contextManager); - } - - public void reset() { - typeNamesByName.clear(); - unloadedByTypeName.clear(); - innerBeanManager.reset(); - } - - public SyncBeanManager getInnerBeanManager() { - return innerBeanManager; - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - public void registerAsyncBean(final FactoryHandle handle, final FactoryLoader future) { - final String beanName; - if (handle.getBeanName() != null) { - beanName = handle.getBeanName(); - } else { - beanName = handle.getActualType().getName(); - } - - typeNamesByName.put(beanName, handle.getActualType().getName()); - - final UnloadedFactory unloaded = new UnloadedFactory(handle, future); - for (final Class assignable : handle.getAssignableTypes()) { - unloadedByTypeName.put(assignable.getName(), unloaded); - } - unloadedByFactoryName.put(handle.getFactoryName(), unloaded); - } - - private void unregisterAsyncBean(final FactoryHandle handle) { - final String name = (handle.getBeanName() != null ? handle.getBeanName() : handle.getActualType().getName()); - typeNamesByName.remove(name, handle.getActualType().getName()); - unloadedByFactoryName.remove(handle.getFactoryName()); - for (final Class assignable : handle.getAssignableTypes()) { - final Iterator> unloadedIter = unloadedByTypeName.get(assignable.getName()).iterator(); - while (unloadedIter.hasNext()) { - final UnloadedFactory unloaded = unloadedIter.next(); - if (unloaded.getHandle().getFactoryName().equals(handle.getFactoryName())) { - unloadedIter.remove(); - break; - } - } - } - } - - @Override - public void registerAsyncDependency(final String dependentFactoryName, final String dependencyFactoryName) { - final UnloadedFactory unloaded = getUnloadedFactory(dependentFactoryName); - unloaded.addAsyncDependency(dependencyFactoryName); - } - - private UnloadedFactory getUnloadedFactory(final String factoryName) { - final UnloadedFactory unloadedFactory = unloadedByFactoryName.get(factoryName); - if (unloadedFactory == null) { - throw new RuntimeException("No unloaded factory found for " + factoryName); - } else { - return unloadedFactory; - } - } - - private class UnloadedFactory { - private final FactoryHandle handle; - private final FactoryLoader loader; - private final Set asyncDependencies = new HashSet<>(); - - private boolean loaded = false; - private boolean loading = false; - private final Queue onLoad = new LinkedList<>(); - - public UnloadedFactory(final FactoryHandle handle, final FactoryLoader loader) { - this.handle = handle; - this.loader = loader; - } - - private void loadSelf(final Runnable whenLoaded) { - if (loaded) { - whenLoaded.run(); - return; - } else if (loading) { - onLoad.add(whenLoaded); - return; - } else { - loading = true; - loader.call(new FactoryLoaderCallback() { - @Override - public void callback(final Factory factory) { - innerBeanManager.addFactory(factory); - unregisterAsyncBean(handle); - whenLoaded.run(); - } - }); - } - } - - public void load(final Runnable onFinish) { - if (loaded) { - onFinish.run(); - return; - } else if (loading) { - onLoad.add(onFinish); - return; - } - - loading = true; - onLoad.add(onFinish); - final RefHolder numLoaded = new RefHolder<>(); - numLoaded.set(0); - final Collection> unloadedDeps = getUnloadedAsyncDependencies(); - - for (final UnloadedFactory unloadedDep : unloadedDeps) { - unloadedDep.loadSelf(new Runnable() { - @Override - public void run() { - numLoaded.set(numLoaded.get()+1); - if (numLoaded.get().equals(unloadedDeps.size()+1)) { - finishLoading(unloadedDeps); - } - } - }); - } - - loader.call(new FactoryLoaderCallback() { - @Override - public void callback(final Factory factory) { - numLoaded.set(numLoaded.get()+1); - innerBeanManager.addFactory(factory); - unregisterAsyncBean(handle); - if (numLoaded.get().equals(unloadedDeps.size()+1)) { - finishLoading(unloadedDeps); - } - } - }); - } - - protected void finishLoading(final Collection> unloadedDeps) { - finishDependencies(unloadedDeps); - finishSelf(); - } - - private void finishDependencies(final Collection> unloadedDeps) { - for (final UnloadedFactory unloaded : unloadedDeps) { - unloaded.finishSelf(); - } - } - - private void finishSelf() { - loading = false; - loaded = true; - while (!onLoad.isEmpty()) { - onLoad.poll().run(); - } - } - - private Collection> getUnloadedAsyncDependencies() { - final Deque> unloadedDeps = new LinkedList<>(); - - final Queue bfsQueue = new LinkedList<>(asyncDependencies); - final Set visited = new HashSet<>(); - visited.add(handle.getFactoryName()); - - while (bfsQueue.size() > 0) { - final String factoryName = bfsQueue.poll(); - if (visited.contains(factoryName)) { - continue; - } - - final UnloadedFactory unloadedDep = unloadedByFactoryName.get(factoryName); - if (unloadedDep != null && !unloadedDep.loaded) { - unloadedDeps.addFirst(unloadedDep); - visited.add(factoryName); - for (final String dependentFactoryName : unloadedDep.asyncDependencies) { - bfsQueue.add(dependentFactoryName); - } - } - } - - return unloadedDeps; - } - - public FactoryHandle getHandle() { - return handle; - } - - public void addAsyncDependency(final String factoryName) { - asyncDependencies.add(factoryName); - } - - public FactoryLoaderBeanDef createBeanDef(final Class type) { - return new FactoryLoaderBeanDef(type); - } - - private class FactoryLoaderBeanDef implements AsyncBeanDef { - - private final Class type; - private Set qualifiers; - - public FactoryLoaderBeanDef(final Class type) { - this.type = type; - } - - @Override - public Class getType() { - return type; - } - - @Override - public Class getBeanClass() { - return handle.getActualType(); - } - - @Override - public Class getScope() { - return handle.getScope(); - } - - @Override - public void getInstance(final CreationalCallback callback) { - getInstanceHelper(callback, new Provider() { - @Override - public T get() { - return performSyncLookup().getInstance(); - } - }); - } - - @Override - public void newInstance(final CreationalCallback callback) { - getInstanceHelper(callback, new Provider() { - @Override - public T get() { - return performSyncLookup().newInstance(); - } - }); - } - - private void getInstanceHelper(final CreationalCallback callback, final Provider instanceProvider) { - if (!loaded) { - load(new Runnable() { - @Override - public void run() { - callback.callback(instanceProvider.get()); - } - }); - } else { - callback.callback(instanceProvider.get()); - } - } - - private SyncBeanDef performSyncLookup() { - return innerBeanManager.lookupBean(type, handle.getQualifiers().toArray(new Annotation[0])); - } - - @Override - public Set getQualifiers() { - if (qualifiers == null) { - qualifiers = Collections.unmodifiableSet(new HashSet<>(handle.getQualifiers())); - } - return qualifiers; - } - - @Override - public boolean matches(final Set annotations) { - return QualifierUtil.matches(handle.getQualifiers(), annotations); - } - - @Override - public String getName() { - return handle.getBeanName(); - } - - @Override - public boolean isActivated() { - return true; - } - - @Override - public String toString() { - return BeanManagerUtil.beanDeftoString(handle); - } - - @Override - public boolean isAssignableTo(final Class type) { - return handle.getAssignableTypes().contains(type); - } - - } - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/async/AsyncBeanManagerSetup.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/async/AsyncBeanManagerSetup.java deleted file mode 100644 index 650450c1712..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/async/AsyncBeanManagerSetup.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container.async; - -import org.jboss.errai.ioc.client.container.Factory; -import org.jboss.errai.ioc.client.container.FactoryHandle; - -/** - * - * @author Max Barkley - */ -public interface AsyncBeanManagerSetup { - - void registerAsyncBean(FactoryHandle handle, FactoryLoader future); - - void registerAsyncDependency(String dependentFactoryName, String dependencyFactoryName); - - public static interface FactoryLoaderCallback { - void callback(Factory factory); - } - - public static interface FactoryLoader { - void call(FactoryLoaderCallback callback); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/async/AsyncBeanNotLoaded.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/async/AsyncBeanNotLoaded.java deleted file mode 100644 index 193e4ddfe8b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/async/AsyncBeanNotLoaded.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container.async; - -/** - * @author Mike Brock - */ -public class AsyncBeanNotLoaded extends RuntimeException { -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/async/AsyncBeanQuery.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/async/AsyncBeanQuery.java deleted file mode 100644 index 14a5efc97eb..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/async/AsyncBeanQuery.java +++ /dev/null @@ -1,252 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container.async; - -import java.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.jboss.errai.common.client.api.Assert; -import org.jboss.errai.common.client.util.CreationalCallback; -import org.jboss.errai.ioc.client.container.IOC; - -/** - * An AsyncBeanQuery is used for querying more than one bean at a time, and then orchestrating - * a unit of work to happen only after all of the beans in the query have been successfully loaded. - *

- * For instance, you may need to load two or more beans dynamically from the bean manager in order to - * accomplish some task. Instead of chaining a series of callbacks, which can become difficult to understand - * and maintain, you can instead construct a query for the set of beans you need. - *

- * Example: - *


- * AsyncBeanQuery beanQuery = new AsyncBeanQuery();
- * final AsyncBeanFuture beanAFuture = beanQuery.load(BeanA.class);
- * final AsyncBeanFuture beanBFuture = beanQuery.load(BeanB.class);
- * 

- * beanQuery.query(new Runnable() { - * public void run() { - * BeanA beanA = beanAFuture.get(); - * BeanB beanB = beanBFuture.get(); - * // do some work. - * } - * }); - *

- *

- * In the above example, the Runnable passed to {@link #query(Runnable)} will be executed only after - * all the beans requested with the previous {@link #load(AsyncBeanDef)} calls have been satisfied. - * - * @author Mike Brock - * @since 3.0 - */ -public class AsyncBeanQuery { - private boolean cancelled = false; - private Runnable finishCallback; - - private final List loadStrategies - = new ArrayList(); - - private final Set loaded - = new HashSet(); - - /** - * Requests that the specified bean of the specified {@param type} is loaded. - * - * @param type - * the type of the bean to be loaded. See: {@link AsyncBeanManagerImpl#lookupBean(Class, java.lang.annotation.Annotation...)} - * @param - * the type of bean to be loaded. - * - * @return an {@link AsyncBeanFuture} which will house the instance of the bean once it is loaded. - */ - public AsyncBeanFuture load(final Class type) { - return load(IOC.getAsyncBeanManager().lookupBean(type)); - } - - /** - * Requests that the specified bean of the specified {@param type} and {@param qualifiers} is loaded. - * - * @param type - * the type of the bean to be loaded. See: {@link AsyncBeanManagerImpl#lookupBean(Class, java.lang.annotation.Annotation...)} - * @param qualifiers - * the qualifiers for the bean to be loaded. - * @param - * the type of bean to be loaded. - * - * @return an {@link AsyncBeanFuture} which will house the instance of the bean once it is loaded. - */ - public AsyncBeanFuture load(final Class type, final Annotation... qualifiers) { - return load(IOC.getAsyncBeanManager().lookupBean(type, qualifiers)); - } - - /** - * Requests that the bean described by the specified {@link AsyncBeanDef} is loaded. - * - * @param beanDef - * the {@link AsyncBeanDef} describing the bean to be loaded. - * @param - * the type of bean to be loaded. - * - * @return an {@link AsyncBeanFuture} which will house the instance of the bean once it is loaded. - */ - public AsyncBeanFuture load(final AsyncBeanDef beanDef) { - return load(beanDef, false); - } - - /** - * Requests that a new instance specified bean of the specified {@param type} is loaded. - * - * @param type - * the type of the bean to be loaded. See: {@link AsyncBeanManagerImpl#lookupBean(Class, java.lang.annotation.Annotation...)} - * @param - * the type of bean to be loaded. - * - * @return an {@link AsyncBeanFuture} which will house the instance of the bean once it is loaded. - */ - public AsyncBeanFuture loadNew(final Class type) { - return loadNew(IOC.getAsyncBeanManager().lookupBean(type)); - } - - /** - * Requests that a new instance of specified bean of the specified {@param type} and {@param qualifiers} is loaded. - * - * @param type - * the type of the bean to be loaded. See: {@link AsyncBeanManagerImpl#lookupBean(Class, java.lang.annotation.Annotation...)} - * @param qualifiers - * the qualifiers for the bean to be loaded. - * @param - * the type of bean to be loaded. - * - * @return an {@link AsyncBeanFuture} which will house the instance of the bean once it is loaded. - */ - public AsyncBeanFuture loadNew(final Class type, final Annotation... qualifiers) { - return loadNew(IOC.getAsyncBeanManager().lookupBean(type, qualifiers)); - } - - /** - * Requests that a new instance of the bean described by the specified {@link AsyncBeanDef} is loaded. - * - * @param beanDef - * the {@link AsyncBeanDef} describing the bean to be loaded. - * @param - * the type of bean to be loaded. - * - * @return an {@link AsyncBeanFuture} which will house the instance of the bean once it is loaded. - */ - public AsyncBeanFuture loadNew(final AsyncBeanDef beanDef) { - return load(beanDef, true); - } - - private AsyncBeanFuture load(final AsyncBeanDef beanDef, final boolean loadNew) { - final LoadStrategy loadStrategy = new LoadStrategy(beanDef, loadNew); - loadStrategies.add(loadStrategy); - return loadStrategy.getFuture(); - } - - /** - * Initiates the constructed query based on {@link #load(AsyncBeanDef)} and {@link #loadNew(AsyncBeanDef)} calls - * made prior to calling this method. The specified Runnable is invoked only after all the requested - * beans have been successfully loaded. - * - * @param finishCallback - * the Runnable to be invoked once all of the request beans have been loaded. - */ - public void query(final Runnable finishCallback) { - Assert.notNull(finishCallback); - - this.finishCallback = finishCallback; - - for (final LoadStrategy strategy : loadStrategies) { - strategy.load(); - } - } - - /** - * Cancels the query if it has not yet returned. Already loaded beans are destroyed. - */ - public void cancelQuery() { - cancelled = true; - - for (final LoadStrategy strategy : loaded) { - final AsyncBeanFuture future = strategy.getFuture(); - IOC.getAsyncBeanManager().destroyBean(future.get()); - } - - loaded.clear(); - loadStrategies.clear(); - } - - private void vote(LoadStrategy strategy) { - if (cancelled) { - IOC.getAsyncBeanManager().destroyBean(strategy.getFuture().get()); - return; - } - - loaded.add(strategy); - - if (loaded.containsAll(loadStrategies)) { - finishCallback.run(); - } - } - - private class LoadStrategy { - private final AsyncBeanDef beanDef; - private final AsyncBeanFuture future; - private final boolean loadNew; - - private LoadStrategy(final AsyncBeanDef beanDef, final boolean loadNew) { - this.beanDef = beanDef; - this.loadNew = loadNew; - - this.future = new AsyncBeanFuture(new CreationalCallback() { - @Override - public void callback(T beanInstance) { - vote(LoadStrategy.this); - } - }); - } - - - AsyncBeanDef getBeanDef() { - return beanDef; - } - - AsyncBeanFuture getFuture() { - return future; - } - - boolean isLoadNew() { - return loadNew; - } - - void load() { - - if (loadNew) { - beanDef.newInstance(future.getCreationalCallback()); - } - else { - beanDef.getInstance(future.getCreationalCallback()); - } - } - } -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/async/DefaultRunAsyncCallback.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/async/DefaultRunAsyncCallback.java deleted file mode 100644 index 99befa4a943..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/async/DefaultRunAsyncCallback.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container.async; - -import com.google.gwt.core.client.RunAsyncCallback; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * - * @author Max Barkley - */ -public abstract class DefaultRunAsyncCallback implements RunAsyncCallback { - - private static final Logger log = LoggerFactory.getLogger(AsyncBeanManager.class); - - @Override - public void onFailure(final Throwable reason) { - log.error("An error occurred while attempting to download a code fragment.", reason); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/async/SyncToAsyncBeanDef.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/async/SyncToAsyncBeanDef.java deleted file mode 100644 index 809935943a3..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/container/async/SyncToAsyncBeanDef.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.container.async; - -import java.lang.annotation.Annotation; -import java.util.Set; - -import org.jboss.errai.common.client.util.CreationalCallback; -import org.jboss.errai.ioc.client.container.SyncBeanDef; - -/** - * - * @author Max Barkley - */ -public class SyncToAsyncBeanDef implements AsyncBeanDef { - - private final SyncBeanDef beanDef; - - public SyncToAsyncBeanDef(final SyncBeanDef beanDef) { - this.beanDef = beanDef; - } - - @Override - public Class getType() { - return beanDef.getType(); - } - - @Override - public Class getBeanClass() { - return beanDef.getBeanClass(); - } - - @Override - public Class getScope() { - return beanDef.getScope(); - } - - @Override - public Set getQualifiers() { - return beanDef.getQualifiers(); - } - - @Override - public boolean matches(final Set annotations) { - return beanDef.matches(annotations); - } - - @Override - public String getName() { - return beanDef.getName(); - } - - @Override - public boolean isActivated() { - return beanDef.isActivated(); - } - - @Override - public void getInstance(final CreationalCallback callback) { - callback.callback(beanDef.getInstance()); - } - - @Override - public void newInstance(final CreationalCallback callback) { - callback.callback(beanDef.newInstance()); - } - - @Override - public boolean isAssignableTo(final Class type) { - return beanDef.isAssignableTo(type); - } - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/lifecycle/api/Access.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/lifecycle/api/Access.java deleted file mode 100644 index b132052fb8e..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/lifecycle/api/Access.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.lifecycle.api; - -/** - * An event for when an IOC bean instance has a method or field accessed. - * - * @author Max Barkley - */ -public interface Access extends LifecycleEvent { - - /** - * @return True if a method has been accessed. - */ - public boolean isMethodAccess(); - - /** - * @return True if a field has been accessed. - */ - public boolean isFieldAccess(); - - /** - * This must be set before the event is fired. Defaults to false if not set. - * - * @param isMethodAccessed True if a method has been accessed. - */ - public void setIsMethodAccess(boolean isMethodAccessed); - - /** - * This must be set before the event is fired. Defaults to false if not set. - * - * @param isFieldAccessed True if a field has been accessed. - */ - public void setIsFieldAccess(boolean isFieldAccessed); - - /** - * This must be set before the event is fired. - * - * @param methodOrFieldName The name of the field or method that was accessed. - */ - public void setMethodOrFieldName(String methodOrFieldName); - -/** - * @return The name of the field or method that was accessed. - */ - public String getMethodOrFieldName(); - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/lifecycle/api/AuditableLifecycleListener.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/lifecycle/api/AuditableLifecycleListener.java deleted file mode 100644 index 5f469a8164f..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/lifecycle/api/AuditableLifecycleListener.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.lifecycle.api; - -public interface AuditableLifecycleListener extends LifecycleListener { - - public LifecycleListenerGenerator getGenerator(); - - public LifecycleListener unwrap(); - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/lifecycle/api/Creation.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/lifecycle/api/Creation.java deleted file mode 100644 index 8e9486f3bf9..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/lifecycle/api/Creation.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.lifecycle.api; - -/** - * An event for the creation of a new bean instance. - * - * @author Max Barkley - */ -public interface Creation extends LifecycleEvent { - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/lifecycle/api/Destruction.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/lifecycle/api/Destruction.java deleted file mode 100644 index 2fe9265493b..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/lifecycle/api/Destruction.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.lifecycle.api; - -/** - * An event representing the end of an IOC bean instances lifecycle. - * - * This event is special in that, if it is successful (i.e. no listeners - * {@linkplain LifecycleEvent#veto() veto} it) then all references to - * {@link LifecycleListener LifecycleListeners} for this instance will released. - * - * @author Max Barkley - */ -public interface Destruction extends LifecycleEvent { - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/lifecycle/api/LifecycleCallback.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/lifecycle/api/LifecycleCallback.java deleted file mode 100644 index 6f142419cce..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/lifecycle/api/LifecycleCallback.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.lifecycle.api; - -/** - * A callback used by callers of - * {@link LifecycleEvent#fireAsync(LifecycleCallback)}. - * - * @author Max Barkley - */ -public interface LifecycleCallback { - - /** - * A callback used to get the result of a fired {@link LifecycleEvent}. - * - * @param success - * True iff all {@link LifecycleListener LifecycleListeners} for this - * event did not {@linkplain LifecycleEvent#veto() veto}. - */ - public void callback(boolean success); - -} diff --git a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/lifecycle/api/LifecycleEvent.java b/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/lifecycle/api/LifecycleEvent.java deleted file mode 100644 index fdc60dcb3b7..00000000000 --- a/packages/serverless-workflow-diagram-editor/errai-ioc/src/main/java/org/jboss/errai/ioc/client/lifecycle/api/LifecycleEvent.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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 org.jboss.errai.ioc.client.lifecycle.api; - -/** - * The base interface for IOC Lifecycle events. Components may fire IOC Lifecycle events to - * broadcast events to interested listeners that do not perfectly map to one of the supported IOC - * scopes. - * - * The general usage for firing an event is: - * - *

- * Access event = IOC.getBeanManager().lookup(Creation.class).getInstance();
- * // Need to set an instance for the event.
- * event.setInstance("String Instance!");
- * 
- * event.fireAsync(new LifecycleCallback() {
- *      {@code @Override}
- *      public void callback(boolean success) {
- *          if (success) {
- *              // Go through with the action
- *          }
- *      }
- * });
- * 
- * - * {@link LifecycleListener LifecycleListeners} can {@linkplain #getInstance() access the event - * instance} or {@linkplain #veto() veto the event}. - * - * @author Max Barkley - */ -public interface LifecycleEvent { - - /** - * Fire this event, notifying any listeners for this event type by calling the respective - * {@link LifecycleListener#observeEvent(LifecycleEvent)} methods. - * - * @param instance - * The bean instance associated with this event. - */ - public void fireAsync(T instance); - - /** - * Fire this event, notifying any listeners for this event type by calling the respective - * {@link LifecycleListener#observeEvent(LifecycleEvent)} methods. - * - * @param instance - * The bean instance associated with this event. - * - * @param callback - * A callback for receiving the result of a fired event (whether or not any listeners - * {@linkplain #veto() vetoed}. - */ - public void fireAsync(T instance, LifecycleCallback callback); - - /** - * Veto this event. If this method is called by a {@link LifecycleListener} during the - * {@link LifecycleListener#observeEvent(LifecycleEvent)} then: - *