You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by ld...@apache.org on 2012/02/23 00:08:09 UTC

svn commit: r1292573 - in /karaf/webconsole/trunk/examples: ./ scala/ scala/src/ scala/src/main/ scala/src/main/resources/ scala/src/main/resources/OSGI-INF/ scala/src/main/resources/OSGI-INF/blueprint/ scala/src/main/resources/org/ scala/src/main/reso...

Author: ldywicki
Date: Wed Feb 22 23:08:08 2012
New Revision: 1292573

URL: http://svn.apache.org/viewvc?rev=1292573&view=rev
Log:
Add scala example for webconsole. It requires scala runtime to work, and does the job.

Added:
    karaf/webconsole/trunk/examples/scala/
    karaf/webconsole/trunk/examples/scala/pom.xml
    karaf/webconsole/trunk/examples/scala/src/
    karaf/webconsole/trunk/examples/scala/src/main/
    karaf/webconsole/trunk/examples/scala/src/main/resources/
    karaf/webconsole/trunk/examples/scala/src/main/resources/OSGI-INF/
    karaf/webconsole/trunk/examples/scala/src/main/resources/OSGI-INF/blueprint/
    karaf/webconsole/trunk/examples/scala/src/main/resources/OSGI-INF/blueprint/jmx.xml   (contents, props changed)
      - copied, changed from r1291796, karaf/webconsole/trunk/examples/pom.xml
    karaf/webconsole/trunk/examples/scala/src/main/resources/org/
    karaf/webconsole/trunk/examples/scala/src/main/resources/org/apache/
    karaf/webconsole/trunk/examples/scala/src/main/resources/org/apache/karaf/
    karaf/webconsole/trunk/examples/scala/src/main/resources/org/apache/karaf/webconsole/
    karaf/webconsole/trunk/examples/scala/src/main/resources/org/apache/karaf/webconsole/examples/
    karaf/webconsole/trunk/examples/scala/src/main/resources/org/apache/karaf/webconsole/examples/scala/
    karaf/webconsole/trunk/examples/scala/src/main/resources/org/apache/karaf/webconsole/examples/scala/ExampleScalaPage.html
    karaf/webconsole/trunk/examples/scala/src/main/scala/
    karaf/webconsole/trunk/examples/scala/src/main/scala/org/
    karaf/webconsole/trunk/examples/scala/src/main/scala/org/apache/
    karaf/webconsole/trunk/examples/scala/src/main/scala/org/apache/karaf/
    karaf/webconsole/trunk/examples/scala/src/main/scala/org/apache/karaf/webconsole/
    karaf/webconsole/trunk/examples/scala/src/main/scala/org/apache/karaf/webconsole/examples/
    karaf/webconsole/trunk/examples/scala/src/main/scala/org/apache/karaf/webconsole/examples/scala/
    karaf/webconsole/trunk/examples/scala/src/main/scala/org/apache/karaf/webconsole/examples/scala/ExampleScalaPage.scala
    karaf/webconsole/trunk/examples/scala/src/main/scala/org/apache/karaf/webconsole/examples/scala/ScalaNavigationProvider.scala
Modified:
    karaf/webconsole/trunk/examples/pom.xml

Modified: karaf/webconsole/trunk/examples/pom.xml
URL: http://svn.apache.org/viewvc/karaf/webconsole/trunk/examples/pom.xml?rev=1292573&r1=1292572&r2=1292573&view=diff
==============================================================================
--- karaf/webconsole/trunk/examples/pom.xml (original)
+++ karaf/webconsole/trunk/examples/pom.xml Wed Feb 22 23:08:08 2012
@@ -34,6 +34,7 @@
         <module>branding</module>
         <module>events</module>
         <module>scr</module>
+        <module>scala</module>
     </modules>
 
 </project>

Added: karaf/webconsole/trunk/examples/scala/pom.xml
URL: http://svn.apache.org/viewvc/karaf/webconsole/trunk/examples/scala/pom.xml?rev=1292573&view=auto
==============================================================================
--- karaf/webconsole/trunk/examples/scala/pom.xml (added)
+++ karaf/webconsole/trunk/examples/scala/pom.xml Wed Feb 22 23:08:08 2012
@@ -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>

Copied: karaf/webconsole/trunk/examples/scala/src/main/resources/OSGI-INF/blueprint/jmx.xml (from r1291796, karaf/webconsole/trunk/examples/pom.xml)
URL: http://svn.apache.org/viewvc/karaf/webconsole/trunk/examples/scala/src/main/resources/OSGI-INF/blueprint/jmx.xml?p2=karaf/webconsole/trunk/examples/scala/src/main/resources/OSGI-INF/blueprint/jmx.xml&p1=karaf/webconsole/trunk/examples/pom.xml&r1=1291796&r2=1292573&rev=1292573&view=diff
==============================================================================
--- karaf/webconsole/trunk/examples/pom.xml (original)
+++ karaf/webconsole/trunk/examples/scala/src/main/resources/OSGI-INF/blueprint/jmx.xml Wed Feb 22 23:08:08 2012
@@ -15,25 +15,12 @@
    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>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
 
-    <parent>
-        <groupId>org.apache.karaf</groupId>
-        <artifactId>webconsole</artifactId>
-        <version>0.3.0-SNAPSHOT</version>
-    </parent>
+    <reference id="mbeanServer" interface="javax.management.MBeanServer" />
 
-    <groupId>org.apache.karaf.webconsole</groupId>
-    <artifactId>examples</artifactId>
-    <name>Apache Karaf :: WebConsole :: Examples</name>
-    <packaging>pom</packaging>
+    <service auto-export="interfaces">
+        <bean class="org.apache.karaf.webconsole.examples.scala.ScalaNavigationProvider" />
+    </service>
 
-    <modules>
-        <module>branding</module>
-        <module>events</module>
-        <module>scr</module>
-    </modules>
-
-</project>
+</blueprint>
\ No newline at end of file

Propchange: karaf/webconsole/trunk/examples/scala/src/main/resources/OSGI-INF/blueprint/jmx.xml
------------------------------------------------------------------------------
    svn:executable = *

Added: karaf/webconsole/trunk/examples/scala/src/main/resources/org/apache/karaf/webconsole/examples/scala/ExampleScalaPage.html
URL: http://svn.apache.org/viewvc/karaf/webconsole/trunk/examples/scala/src/main/resources/org/apache/karaf/webconsole/examples/scala/ExampleScalaPage.html?rev=1292573&view=auto
==============================================================================
--- karaf/webconsole/trunk/examples/scala/src/main/resources/org/apache/karaf/webconsole/examples/scala/ExampleScalaPage.html (added)
+++ karaf/webconsole/trunk/examples/scala/src/main/resources/org/apache/karaf/webconsole/examples/scala/ExampleScalaPage.html Wed Feb 22 23:08:08 2012
@@ -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

Added: karaf/webconsole/trunk/examples/scala/src/main/scala/org/apache/karaf/webconsole/examples/scala/ExampleScalaPage.scala
URL: http://svn.apache.org/viewvc/karaf/webconsole/trunk/examples/scala/src/main/scala/org/apache/karaf/webconsole/examples/scala/ExampleScalaPage.scala?rev=1292573&view=auto
==============================================================================
--- karaf/webconsole/trunk/examples/scala/src/main/scala/org/apache/karaf/webconsole/examples/scala/ExampleScalaPage.scala (added)
+++ karaf/webconsole/trunk/examples/scala/src/main/scala/org/apache/karaf/webconsole/examples/scala/ExampleScalaPage.scala Wed Feb 22 23:08:08 2012
@@ -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()));
+    }
+  });
+
+}

Added: karaf/webconsole/trunk/examples/scala/src/main/scala/org/apache/karaf/webconsole/examples/scala/ScalaNavigationProvider.scala
URL: http://svn.apache.org/viewvc/karaf/webconsole/trunk/examples/scala/src/main/scala/org/apache/karaf/webconsole/examples/scala/ScalaNavigationProvider.scala?rev=1292573&view=auto
==============================================================================
--- karaf/webconsole/trunk/examples/scala/src/main/scala/org/apache/karaf/webconsole/examples/scala/ScalaNavigationProvider.scala (added)
+++ karaf/webconsole/trunk/examples/scala/src/main/scala/org/apache/karaf/webconsole/examples/scala/ScalaNavigationProvider.scala Wed Feb 22 23:08:08 2012
@@ -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]];
+
+}