felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1203551 [4/4] - in /felix/trunk/webconsole-plugins/servicediagnostics: ./ core/ core/src/ core/src/main/ core/src/main/resources/ core/src/main/resources/html/ core/src/main/resources/html/js/ core/src/main/scala/ core/src/main/scala/servi...
Date Fri, 18 Nov 2011 09:40:51 GMT
Propchange: felix/trunk/webconsole-plugins/servicediagnostics/run.sh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/webconsole-plugins/servicediagnostics/run.sh
------------------------------------------------------------------------------
    svn:executable = *

Propchange: felix/trunk/webconsole-plugins/servicediagnostics/run.sh
------------------------------------------------------------------------------
    svn:keywords = Id

Added: felix/trunk/webconsole-plugins/servicediagnostics/sample/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/servicediagnostics/sample/pom.xml?rev=1203551&view=auto
==============================================================================
--- felix/trunk/webconsole-plugins/servicediagnostics/sample/pom.xml (added)
+++ felix/trunk/webconsole-plugins/servicediagnostics/sample/pom.xml Fri Nov 18 09:40:49 2011
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd">
+  
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.felix</groupId>
+    <artifactId>servicediagnostics</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+    <relativePath>../pom.xml</relativePath>
+  </parent>
+
+  <groupId>org.apache.felix</groupId>
+  <artifactId>servicediagnostics.sample</artifactId>
+  <version>1.0.0-SNAPSHOT</version>
+  <packaging>bundle</packaging>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.felix</groupId>
+      <artifactId>servicediagnostics.core</artifactId>
+      <version>1.0.0-SNAPSHOT</version>
+    </dependency>
+    <!-- runtime dependencies. added to populate the local repository -->
+    <dependency>
+      <groupId>org.apache.felix</groupId>
+      <artifactId>org.apache.felix.main</artifactId>
+      <version>3.2.2</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.felix</groupId>
+      <artifactId>org.apache.felix.http.jetty</artifactId>
+      <version>2.2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.felix</groupId>
+      <artifactId>org.apache.felix.shell</artifactId>
+      <version>1.4.2</version>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.scala-tools</groupId>
+        <artifactId>maven-scala-plugin</artifactId>
+      </plugin>
+
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <configuration>
+          <instructions>
+            <Bundle-Category>osgi</Bundle-Category>
+            <Bundle-SymbolicName>
+              ${project.artifactId}
+            </Bundle-SymbolicName>
+            <Service-Component>
+              *
+            </Service-Component>
+            <Private-Package>
+              org.apache.felix.servicediagnostics.sample
+            </Private-Package>
+            <Import-Package>
+              !aQute.bnd.annotation.component,!org.apache.felix.main,*
+            </Import-Package>
+          </instructions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  
+</project>

Propchange: felix/trunk/webconsole-plugins/servicediagnostics/sample/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/webconsole-plugins/servicediagnostics/sample/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: felix/trunk/webconsole-plugins/servicediagnostics/sample/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/trunk/webconsole-plugins/servicediagnostics/sample/src/main/scala/servicediagnostics/sample/FelixLauncher.scala
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/servicediagnostics/sample/src/main/scala/servicediagnostics/sample/FelixLauncher.scala?rev=1203551&view=auto
==============================================================================
--- felix/trunk/webconsole-plugins/servicediagnostics/sample/src/main/scala/servicediagnostics/sample/FelixLauncher.scala
(added)
+++ felix/trunk/webconsole-plugins/servicediagnostics/sample/src/main/scala/servicediagnostics/sample/FelixLauncher.scala
Fri Nov 18 09:40:49 2011
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR 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.felix.servicediagnostics.sample
+
+import java.util.HashMap
+import java.util.ServiceLoader
+
+import scala.io.Source
+
+import org.osgi.framework.launch.FrameworkFactory
+import org.apache.felix.main.AutoProcessor
+
+/**
+ * This is a simple launcher for the framework, that doesn't require a properties file. 
+ * Bundles to be started are simply given in the command line.
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+object FelixLauncher
+{
+    def main(bundles:Array[String]) = 
+    {
+        // load the FrameworkFactory implementation
+        val factory:FrameworkFactory = ServiceLoader.load(classOf[FrameworkFactory],
+            getClass.getClassLoader).iterator.next
+        // set our hardcoded felix.properties
+        val felixProps = new HashMap[String, String]
+        felixProps.put("org.osgi.framework.storage", ".cache")
+        felixProps.put("org.osgi.framework.storage.clean", "onFirstInit")
+        felixProps.put("felix.auto.install", bundles.map("file:"+_).mkString(" "))
+        felixProps.put("felix.auto.start", bundles.map("file:"+_).mkString(" "))
+        felixProps.put("org.osgi.framework.bootdelegation", "sun.*,com.sun.*")
+
+        //println("Launch Felix using "+factory+" and "+felixProps)
+        val felix = factory.newFramework(felixProps)
+        felix.init
+        // let the AutoProcessor process the properties (auto.install and auto.start)
+        AutoProcessor.process(felixProps, felix.getBundleContext)
+        // launch felix
+        felix.start
+        //println("Felix started")
+    }
+}

Added: felix/trunk/webconsole-plugins/servicediagnostics/sample/src/main/scala/servicediagnostics/sample/TestDM.scala
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/servicediagnostics/sample/src/main/scala/servicediagnostics/sample/TestDM.scala?rev=1203551&view=auto
==============================================================================
--- felix/trunk/webconsole-plugins/servicediagnostics/sample/src/main/scala/servicediagnostics/sample/TestDM.scala
(added)
+++ felix/trunk/webconsole-plugins/servicediagnostics/sample/src/main/scala/servicediagnostics/sample/TestDM.scala
Fri Nov 18 09:40:49 2011
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR 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.felix.servicediagnostics.sample
+
+import org.osgi.framework.BundleContext
+import org.apache.felix.dm.DependencyActivatorBase
+import org.apache.felix.dm.DependencyManager
+import org.apache.felix.servicediagnostics.ServiceDiagnostics
+
+/**
+ * This class is a basic DependencyManager based demonstration
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+class TestDM extends DependencyActivatorBase
+{
+    var diagnostics:ServiceDiagnostics = _ //injected
+
+    override def init(bc:BundleContext, dm:DependencyManager) 
+    {
+        // register a callback in this class to try the engine alone
+        // in text mode, when everything is started
+        dm.add(createComponent
+            .setImplementation(this)
+            .add(createServiceDependency
+                .setService(classOf[TestDS]) // also wait for DS initialization
+                .setAutoConfig(false)
+                .setRequired(true))
+            .add(createServiceDependency
+                .setService(classOf[ServiceDiagnostics])
+                .setAutoConfig("diagnostics")
+                .setRequired(true)))
+
+        // initialize some sample services for testing purpose (see also TestDS)
+        dm.add(createComponent
+            .setInterface(classOf[DM1].getName, null)
+            .setImplementation(classOf[DM1])
+            .add(createServiceDependency
+                .setService(classOf[DM2])
+                .setAutoConfig(false)
+                .setCallbacks(null, null, null)
+                .setRequired(true)))
+
+        dm.add(createComponent
+            .setInterface(classOf[DM2].getName, null)
+            .setImplementation(classOf[DM2])
+            .add(createServiceDependency
+                .setService(classOf[DM3])
+                .setAutoConfig(false)
+                .setCallbacks(null, null, null)
+                .setRequired(true)))
+
+        dm.add(createComponent
+            .setInterface(classOf[DM3].getName, null)
+            .setImplementation(classOf[DM3])
+            .add(createServiceDependency
+                .setService(classOf[Runnable]) //missing dependency
+                .setAutoConfig(false)
+                .setCallbacks(null, null, null)
+                .setRequired(true)))
+    }
+
+    override def destroy(bc:BundleContext, dm:DependencyManager) = {}
+
+    def start = 
+    {
+        println("unavail="+diagnostics.notavail)
+        println("all="+diagnostics.allServices)
+    }
+}
+
+//sample service classes
+class DM1
+class DM2
+class DM3

Added: felix/trunk/webconsole-plugins/servicediagnostics/sample/src/main/scala/servicediagnostics/sample/TestDS.scala
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/servicediagnostics/sample/src/main/scala/servicediagnostics/sample/TestDS.scala?rev=1203551&view=auto
==============================================================================
--- felix/trunk/webconsole-plugins/servicediagnostics/sample/src/main/scala/servicediagnostics/sample/TestDS.scala
(added)
+++ felix/trunk/webconsole-plugins/servicediagnostics/sample/src/main/scala/servicediagnostics/sample/TestDS.scala
Fri Nov 18 09:40:49 2011
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR 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.felix.servicediagnostics.sample
+
+import aQute.bnd.annotation.component._
+
+/**
+ * This class is a basic SCR based demonstration
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+@Component(immediate=true, provide=Array(classOf[TestDS])) class TestDS 
+
+@Component(provide=Array(classOf[DS1])) class DS1 
+{
+    @Reference def setDS2(s:DS2) = {}
+}
+
+@Component(provide=Array(classOf[DS2])) class DS2 
+{
+    @Reference def setDM3(s:DM3) = {}
+}
+
+@Component(provide=Array(classOf[DS3])) class DS3 
+{
+    @Reference def setMap(s:java.util.Map[String,String]) = {} //not available
+}



Mime
View raw message