From a2ae42256babd89a313de12eae62ffadd38e04cc Mon Sep 17 00:00:00 2001 From: Thomas Vachuska Date: Wed, 29 Apr 2015 18:42:09 -0700 Subject: [PATCH] Added onos-ui-archetype as a partial archetype to bootstrap UI development. Modified onos-cli-archetype to be a partial archetype. Change-Id: I172bca5f67519f052bbb116486b3f1d7c51bc4bf --- .../META-INF/maven/archetype-metadata.xml | 24 ++-- .../META-INF/maven/archetype-metadata.xml | 36 ++--- .../resources/archetype-resources/pom.xml | 4 + .../src/main/java/AppComponent.java | 2 +- .../META-INF/maven/archetype-metadata.xml | 36 ++--- tools/package/archetypes/pom.xml | 1 + tools/package/archetypes/ui/pom.xml | 31 ++++ .../META-INF/maven/archetype-metadata.xml | 38 +++++ .../resources/archetype-resources/pom.xml | 132 ++++++++++++++++++ .../src/main/java/AppUiComponent.java | 90 ++++++++++++ .../main/resources/app/view/sample/sample.css | 16 +++ .../resources/app/view/sample/sample.html | 7 + .../main/resources/app/view/sample/sample.js | 16 +++ .../src/main/resources/css.html | 1 + .../src/main/resources/js.html | 1 + .../projects/basic/archetype.properties | 21 +++ .../test/resources/projects/basic/goal.txt | 0 tools/test/bin/onos-archetypes-test | 2 +- 18 files changed, 411 insertions(+), 47 deletions(-) create mode 100644 tools/package/archetypes/ui/pom.xml create mode 100644 tools/package/archetypes/ui/src/main/resources/META-INF/maven/archetype-metadata.xml create mode 100644 tools/package/archetypes/ui/src/main/resources/archetype-resources/pom.xml create mode 100644 tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/java/AppUiComponent.java create mode 100644 tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.css create mode 100644 tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.html create mode 100644 tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.js create mode 100644 tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/css.html create mode 100644 tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/js.html create mode 100644 tools/package/archetypes/ui/src/test/resources/projects/basic/archetype.properties create mode 100644 tools/package/archetypes/ui/src/test/resources/projects/basic/goal.txt diff --git a/tools/package/archetypes/api/src/main/resources/META-INF/maven/archetype-metadata.xml b/tools/package/archetypes/api/src/main/resources/META-INF/maven/archetype-metadata.xml index 5057fbfb10..e35285e6f4 100644 --- a/tools/package/archetypes/api/src/main/resources/META-INF/maven/archetype-metadata.xml +++ b/tools/package/archetypes/api/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -14,15 +14,17 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - - - - src/main/java - - **/*.java - - - + + + + src/main/java + + **/*.java + + + diff --git a/tools/package/archetypes/bundle/src/main/resources/META-INF/maven/archetype-metadata.xml b/tools/package/archetypes/bundle/src/main/resources/META-INF/maven/archetype-metadata.xml index b33574afbf..ef60bd05c7 100644 --- a/tools/package/archetypes/bundle/src/main/resources/META-INF/maven/archetype-metadata.xml +++ b/tools/package/archetypes/bundle/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -14,21 +14,23 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - - - - src/main/java - - **/*.java - - - - src/test/java - - **/*.java - - - + + + + src/main/java + + **/*.java + + + + src/test/java + + **/*.java + + + diff --git a/tools/package/archetypes/bundle/src/main/resources/archetype-resources/pom.xml b/tools/package/archetypes/bundle/src/main/resources/archetype-resources/pom.xml index fcfa8b520a..2b9a2b6528 100644 --- a/tools/package/archetypes/bundle/src/main/resources/archetype-resources/pom.xml +++ b/tools/package/archetypes/bundle/src/main/resources/archetype-resources/pom.xml @@ -27,6 +27,10 @@ 1.2.0-SNAPSHOT + diff --git a/tools/package/archetypes/bundle/src/main/resources/archetype-resources/src/main/java/AppComponent.java b/tools/package/archetypes/bundle/src/main/resources/archetype-resources/src/main/java/AppComponent.java index cd66e59327..693b6fd4fd 100644 --- a/tools/package/archetypes/bundle/src/main/resources/archetype-resources/src/main/java/AppComponent.java +++ b/tools/package/archetypes/bundle/src/main/resources/archetype-resources/src/main/java/AppComponent.java @@ -31,7 +31,7 @@ import org.slf4j.LoggerFactory; @Component(immediate = true) public class AppComponent { - private static Logger log = LoggerFactory.getLogger(AppComponent.class); + private final Logger log = LoggerFactory.getLogger(getClass()); @Activate protected void activate() { diff --git a/tools/package/archetypes/cli/src/main/resources/META-INF/maven/archetype-metadata.xml b/tools/package/archetypes/cli/src/main/resources/META-INF/maven/archetype-metadata.xml index 5f30b85fbf..8558d4768f 100644 --- a/tools/package/archetypes/cli/src/main/resources/META-INF/maven/archetype-metadata.xml +++ b/tools/package/archetypes/cli/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -14,21 +14,23 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - - - - src/main/java - - **/*.java - - - - src/main/resources - - **/*.xml - - - + + + + src/main/java + + **/*.java + + + + src/main/resources + + **/*.xml + + + diff --git a/tools/package/archetypes/pom.xml b/tools/package/archetypes/pom.xml index 5a50cb552b..fe7cf00073 100644 --- a/tools/package/archetypes/pom.xml +++ b/tools/package/archetypes/pom.xml @@ -36,6 +36,7 @@ api bundle cli + ui diff --git a/tools/package/archetypes/ui/pom.xml b/tools/package/archetypes/ui/pom.xml new file mode 100644 index 0000000000..152ee9eeab --- /dev/null +++ b/tools/package/archetypes/ui/pom.xml @@ -0,0 +1,31 @@ + + + + 4.0.0 + + + org.onosproject + onos-archetypes + 1.2.0-SNAPSHOT + + + onos-ui-archetype + maven-archetype + + ONOS UI overlay archetype + + diff --git a/tools/package/archetypes/ui/src/main/resources/META-INF/maven/archetype-metadata.xml b/tools/package/archetypes/ui/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 0000000000..309fd6ad50 --- /dev/null +++ b/tools/package/archetypes/ui/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,38 @@ + + + + + + src/main/java + + **/*.java + + + + src/main/resources + + **/*.html + **/*.js + **/*.css + + + + diff --git a/tools/package/archetypes/ui/src/main/resources/archetype-resources/pom.xml b/tools/package/archetypes/ui/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 0000000000..72b8f8420b --- /dev/null +++ b/tools/package/archetypes/ui/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,132 @@ + + + + 4.0.0 + + ${groupId} + ${artifactId} + ${version} + bundle + + ONOS OSGi UI bundle archetype + http://onosproject.org + + + 1.2.0-SNAPSHOT + + + + + + org.onosproject + onos-api + ${onos.version} + + + + org.onosproject + onlab-osgi + ${onos.version} + + + + junit + junit + 4.11 + test + + + + org.onosproject + onos-api + ${onos.version} + test + tests + + + + org.apache.felix + org.apache.felix.scr.annotations + 1.9.8 + provided + + + + + + + org.apache.felix + maven-bundle-plugin + 2.5.3 + true + + + org.apache.maven.plugins + maven-compiler-plugin + 2.5.1 + + 1.8 + 1.8 + + + + org.apache.felix + maven-scr-plugin + 1.20.0 + + + generate-scr-srcdescriptor + + scr + + + + + + bundle + war + + + + + org.onosproject + onos-maven-plugin + 1.4-SNAPSHOT + + + cfg + generate-resources + + cfg + + + + app + package + + app + + + + + + + + diff --git a/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/java/AppUiComponent.java b/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/java/AppUiComponent.java new file mode 100644 index 0000000000..c052346b2a --- /dev/null +++ b/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/java/AppUiComponent.java @@ -0,0 +1,90 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +/* + * Copyright 2014 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package ${package}; + +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import org.apache.felix.scr.annotations.Activate; +import org.apache.felix.scr.annotations.Component; +import org.apache.felix.scr.annotations.Deactivate; +import org.apache.felix.scr.annotations.Service; +import org.apache.felix.scr.annotations.Reference; +import org.apache.felix.scr.annotations.ReferenceCardinality; +import org.onosproject.ui.UiExtension; +import org.onosproject.ui.UiExtensionService; +import org.onosproject.ui.UiMessageHandler; +import org.onosproject.ui.UiMessageHandlerFactory; +import org.onosproject.ui.UiView; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.List; + +/** + * Skeletal ONOS UI application component. + */ +@Component(immediate = true) +public class AppUiComponent { + + private final Logger log = LoggerFactory.getLogger(getClass()); + + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) + protected UiExtensionService uiExtensionService; + + // List of application views + private final List uiViews = ImmutableList.of( + new UiView(UiView.Category.OTHER, "sample", "Sample") + ); + + // Factory for UI message handlers + private final UiMessageHandlerFactory messageHandlerFactory = + () -> ImmutableList.of( + new AppUiMessageHandler() + ); + + // Application UI exctension + protected UiExtension extension = new UiExtension(uiViews, messageHandlerFactory, + getClass().getClassLoader()); + + @Activate + protected void activate() { + uiExtensionService.register(extension); + log.info("Started"); + } + + @Deactivate + protected void deactivate() { + uiExtensionService.unregister(extension); + log.info("Stopped"); + } + + // Application UI message handler + private class AppUiMessageHandler extends UiMessageHandler { + protected AppUiMessageHandler() { + super(ImmutableSet.of("sampleRequest")); + } + + @Override + public void process(ObjectNode objectNode) { + log.info("We got a message: {}", objectNode); + } + } + +} diff --git a/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.css b/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.css new file mode 100644 index 0000000000..9e4e76130e --- /dev/null +++ b/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.css @@ -0,0 +1,16 @@ +/* css for sample app view */ + +#ov-sample p { + margin: 0 30px; + padding: 10px; + border: 2px solid; +} + +.light #ov-sample p { + color: darkblue; + border-color: #88c; +} +.dark #ov-sample p { + color: #aac; + border-color: #448; +} \ No newline at end of file diff --git a/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.html b/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.html new file mode 100644 index 0000000000..eec3de984a --- /dev/null +++ b/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.html @@ -0,0 +1,7 @@ + + +
+

Sample App View

+ +

{{ctrl.msg}}

+
\ No newline at end of file diff --git a/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.js b/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.js new file mode 100644 index 0000000000..313236e6c6 --- /dev/null +++ b/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sample/sample.js @@ -0,0 +1,16 @@ +// js for sample app view +(function () { + 'use strict'; + + angular.module('ovSample', []) + .controller('OvSampleCtrl', + ['$log', '$scope', + + function ($log, $scope) { + var self = this; + + self.msg = 'A message from our app...'; + + $log.log('OvSampleCtrl has been created'); + }]); +}()); diff --git a/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/css.html b/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/css.html new file mode 100644 index 0000000000..c469725693 --- /dev/null +++ b/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/css.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/js.html b/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/js.html new file mode 100644 index 0000000000..7cacc707c2 --- /dev/null +++ b/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/js.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tools/package/archetypes/ui/src/test/resources/projects/basic/archetype.properties b/tools/package/archetypes/ui/src/test/resources/projects/basic/archetype.properties new file mode 100644 index 0000000000..a1213b40f5 --- /dev/null +++ b/tools/package/archetypes/ui/src/test/resources/projects/basic/archetype.properties @@ -0,0 +1,21 @@ +# +# Copyright 2014 Open Networking Laboratory +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +#Thu Dec 04 09:24:50 PST 2014 +package=it.pkg +version=0.1-SNAPSHOT +groupId=archetype.it +artifactId=basic diff --git a/tools/package/archetypes/ui/src/test/resources/projects/basic/goal.txt b/tools/package/archetypes/ui/src/test/resources/projects/basic/goal.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/test/bin/onos-archetypes-test b/tools/test/bin/onos-archetypes-test index 51a362ca4f..af7d6dd54f 100755 --- a/tools/test/bin/onos-archetypes-test +++ b/tools/test/bin/onos-archetypes-test @@ -7,7 +7,7 @@ export AROOT=/tmp/foo export ARCHETYPE_OPTS="-DarchetypeGroupId=org.onosproject -Dversion=1.2.0-SNAPSHOT" mkdir -p $AROOT -for an in api bundle cli; do +for an in api bundle cli ui; do cd $AROOT rm -fr $AROOT/foo-$an mvn archetype:generate $ARCHETYPE_OPTS \