Skip to content
Browse files

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
  • Loading branch information...
1 parent beef140 commit 48800e61bfe8bff545f196e43eb12baea01ed2ee @splatch splatch committed Feb 22, 2012
View
1 examples/pom.xml
@@ -34,6 +34,7 @@
<module>branding</module>
<module>events</module>
<module>scr</module>
+ <module>scala</module>
</modules>
</project>
View
82 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>
View
26 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>
View
26 ...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>
View
47 ...es/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()));
+ }
+ });
+
+}
View
37 ...a/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]];
+
+}

0 comments on commit 48800e6

Please sign in to comment.
Something went wrong with that request. Please try again.