Add scala example for webconsole. It requires scala runtime to work, and does the job.
git-svn-id: https://svn.apache.org/repos/asf/karaf/webconsole/trunk@1292573 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/examples/pom.xml b/examples/pom.xml
index fffdec3..d66b8be 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -34,6 +34,7 @@
<module>branding</module>
<module>events</module>
<module>scr</module>
+ <module>scala</module>
</modules>
</project>
diff --git a/examples/scala/pom.xml b/examples/scala/pom.xml
new file mode 100644
index 0000000..d519cf8
--- /dev/null
+++ b/examples/scala/pom.xml
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.webconsole</groupId>
+ <artifactId>examples</artifactId>
+ <version>0.3.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.apache.karaf.webconsole.examples</groupId>
+ <artifactId>scala</artifactId>
+ <name>Apache Karaf :: WebConsole :: Examples :: Scala</name>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.karaf.webconsole</groupId>
+ <artifactId>org.apache.karaf.webconsole.core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.scala-lang</groupId>
+ <artifactId>scala-library</artifactId>
+ <version>2.9.1</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.scala-tools</groupId>
+ <artifactId>maven-scala-plugin</artifactId>
+ <version>2.15.2</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>compile</goal>
+ <goal>testCompile</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.3.5</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+ <Import-Package>
+ !org.apache.karaf.webconsole.examples.scala,
+ *,
+ <!-- transient dependencies -->
+ org.ops4j.pax.wicket.api,
+ org.ops4j.pax.wicket.util,
+ org.ops4j.pax.wicket.util.proxy
+ </Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/examples/scala/src/main/resources/OSGI-INF/blueprint/jmx.xml b/examples/scala/src/main/resources/OSGI-INF/blueprint/jmx.xml
new file mode 100755
index 0000000..1fab08f
--- /dev/null
+++ b/examples/scala/src/main/resources/OSGI-INF/blueprint/jmx.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+ <reference id="mbeanServer" interface="javax.management.MBeanServer" />
+
+ <service auto-export="interfaces">
+ <bean class="org.apache.karaf.webconsole.examples.scala.ScalaNavigationProvider" />
+ </service>
+
+</blueprint>
\ No newline at end of file
diff --git a/examples/scala/src/main/resources/org/apache/karaf/webconsole/examples/scala/ExampleScalaPage.html b/examples/scala/src/main/resources/org/apache/karaf/webconsole/examples/scala/ExampleScalaPage.html
new file mode 100644
index 0000000..32ada0b
--- /dev/null
+++ b/examples/scala/src/main/resources/org/apache/karaf/webconsole/examples/scala/ExampleScalaPage.html
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<wicket:extend xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
+ <h1>Scala JMX <small><span wicket:id="version"></span></small></h1>
+
+ <ul class="unstyled">
+ <li wicket:id="domains">
+ <span wicket:id="domain"></span>
+ </li>
+ </ul>
+</wicket:extend>
\ No newline at end of file
diff --git a/examples/scala/src/main/scala/org/apache/karaf/webconsole/examples/scala/ExampleScalaPage.scala b/examples/scala/src/main/scala/org/apache/karaf/webconsole/examples/scala/ExampleScalaPage.scala
new file mode 100644
index 0000000..029192b
--- /dev/null
+++ b/examples/scala/src/main/scala/org/apache/karaf/webconsole/examples/scala/ExampleScalaPage.scala
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.webconsole.examples.scala
+
+import javax.management.MBeanServer
+import org.apache.karaf.webconsole.core.page.SinglePage
+import org.ops4j.pax.wicket.api.PaxWicketBean
+import org.ops4j.pax.wicket.api.PaxWicketMountPoint
+import java.util._
+import collection.JavaConversions._
+import org.apache.wicket.markup.html.list.{ListItem, ListView}
+import org.apache.wicket.markup.html.basic.Label
+
+/**
+ * An example page which is implemented with Scala and uses Pax-Wicket with blueprint
+ * to obtain service reference from OSGi.
+ */
+@PaxWicketMountPoint(mountPoint = "/examples/scala")
+class ExampleScalaPage extends SinglePage {
+
+ @PaxWicketBean(name="mbeanServer") private var server : MBeanServer = _
+
+ add(new Label("version", scala.util.Properties.versionString).setRenderBodyOnly(true))
+
+ // use ArrayList to avoid serialization exceptions, sorry... scala!
+ add(new ListView[String]("domains", new ArrayList[String](server.getDomains().view)) {
+ @Override
+ protected def populateItem(item : ListItem[String]) {
+ item.add(new Label("domain", item.getModelObject()));
+ }
+ });
+
+}
diff --git a/examples/scala/src/main/scala/org/apache/karaf/webconsole/examples/scala/ScalaNavigationProvider.scala b/examples/scala/src/main/scala/org/apache/karaf/webconsole/examples/scala/ScalaNavigationProvider.scala
new file mode 100644
index 0000000..f453b09
--- /dev/null
+++ b/examples/scala/src/main/scala/org/apache/karaf/webconsole/examples/scala/ScalaNavigationProvider.scala
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.webconsole.examples.scala
+
+import java.util._
+import org.apache.karaf.webconsole.core.navigation.ConsoleTabProvider
+import org.apache.karaf.webconsole.core.util.LinkUtils
+import collection.JavaConversions._
+import org.apache.wicket.markup.html.link.Link
+import org.apache.wicket.Page
+
+/**
+ * Navigation provider.
+ */
+class ScalaNavigationProvider extends ConsoleTabProvider {
+
+ def getModuleLink(linkId : String, labelId : String) : Link[Page] = {
+ LinkUtils.createPageLink(linkId, labelId, "Examples", classOf[ExampleScalaPage])
+ }
+
+ def getItems(linkId : String, labelId : String) : List[Link[Page]] = new ArrayList[Link[Page]];
+
+}