You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ge...@apache.org on 2013/03/19 17:03:25 UTC
svn commit: r1458371 - in /servicemix/smx5/trunk: ./ akka/
akka/akka-osgi-aries/ akka/akka-osgi-aries/src/
akka/akka-osgi-aries/src/main/ akka/akka-osgi-aries/src/main/resources/
akka/akka-osgi-aries/src/main/resources/OSGI-INF/ akka/akka-osgi-aries/sr...
Author: gertv
Date: Tue Mar 19 16:03:24 2013
New Revision: 1458371
URL: http://svn.apache.org/r1458371
Log:
SM-2171: Add support for Akka
Added:
servicemix/smx5/trunk/akka/
servicemix/smx5/trunk/akka/akka-osgi-aries/
servicemix/smx5/trunk/akka/akka-osgi-aries/pom.xml
servicemix/smx5/trunk/akka/akka-osgi-aries/src/
servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/
servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/resources/
servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/resources/OSGI-INF/
servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/resources/OSGI-INF/blueprint/
servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/resources/OSGI-INF/blueprint/akka-namespacehandler.xml
servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/resources/org/
servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/resources/org/apache/
servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/resources/org/apache/servicemix/
servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/resources/org/apache/servicemix/akka/
servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/resources/org/apache/servicemix/akka/aries/
servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/resources/org/apache/servicemix/akka/aries/akka.xsd
servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/scala/
servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/scala/org/
servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/scala/org/apache/
servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/scala/org/apache/servicemix/
servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/scala/org/apache/servicemix/akka/
servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/scala/org/apache/servicemix/akka/aries/
servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/scala/org/apache/servicemix/akka/aries/BlueprintActorSystemFactory.scala
servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/scala/org/apache/servicemix/akka/aries/NamespaceHandler.scala
servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/
servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/resources/
servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/resources/log4j.properties
servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/resources/org/
servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/resources/org/apache/
servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/resources/org/apache/servicemix/
servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/resources/org/apache/servicemix/akka/
servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/resources/org/apache/servicemix/akka/aries/
servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/resources/org/apache/servicemix/akka/aries/config.xml
servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/resources/org/apache/servicemix/akka/aries/injection.xml
servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/resources/org/apache/servicemix/akka/aries/simple.xml
servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/scala/
servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/scala/akka/
servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/scala/akka/osgi/
servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/scala/akka/osgi/PojoSRTestSupport.scala
servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/scala/org/
servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/scala/org/apache/
servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/scala/org/apache/servicemix/
servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/scala/org/apache/servicemix/akka/
servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/scala/org/apache/servicemix/akka/aries/
servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/scala/org/apache/servicemix/akka/aries/ActorSystemAwareBean.scala
servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/scala/org/apache/servicemix/akka/aries/NamespaceHandlerTest.scala
servicemix/smx5/trunk/akka/pom.xml
- copied, changed from r1458369, servicemix/smx5/trunk/examples/pom.xml
Modified:
servicemix/smx5/trunk/assemblies/apache-servicemix/src/main/filtered-resources/features.xml
servicemix/smx5/trunk/assemblies/shared/src/main/filtered-resources/pom.xml
servicemix/smx5/trunk/assemblies/shared/src/main/resources/examples-unix-bin.xml
servicemix/smx5/trunk/assemblies/shared/src/main/resources/examples-windows-bin.xml
servicemix/smx5/trunk/examples/akka/akka-camel/pom.xml
servicemix/smx5/trunk/examples/akka/akka-camel/src/main/resources/application.conf
servicemix/smx5/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/examples/akka/CamelBridge.scala
servicemix/smx5/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/examples/akka/Stats.scala
servicemix/smx5/trunk/examples/akka/akka-camel/src/test/scala/org/apache/servicemix/examples/akka/StatsTest.scala
servicemix/smx5/trunk/examples/akka/pom.xml
servicemix/smx5/trunk/examples/pom.xml
servicemix/smx5/trunk/parent/pom.xml
servicemix/smx5/trunk/pom.xml
Added: servicemix/smx5/trunk/akka/akka-osgi-aries/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/akka/akka-osgi-aries/pom.xml?rev=1458371&view=auto
==============================================================================
--- servicemix/smx5/trunk/akka/akka-osgi-aries/pom.xml (added)
+++ servicemix/smx5/trunk/akka/akka-osgi-aries/pom.xml Tue Mar 19 16:03:24 2013
@@ -0,0 +1,148 @@
+<?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">
+
+ <!--
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.servicemix.akka</groupId>
+ <artifactId>akka</artifactId>
+ <version>5.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>org.apache.servicemix.akka.akka-osgi-aries</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache ServiceMix :: Akka Support :: Akka OSGi Aries</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.typesafe.akka</groupId>
+ <artifactId>akka-osgi_2.10</artifactId>
+ <version>${akka.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>org.apache.aries.blueprint.core</artifactId>
+ <version>${aries.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.scala-lang</groupId>
+ <artifactId>scala-library</artifactId>
+ <version>${scala.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.aries.proxy</groupId>
+ <artifactId>org.apache.aries.proxy.impl</artifactId>
+ <version>${aries.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>${slf4j.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.scalatest</groupId>
+ <artifactId>scalatest_2.10</artifactId>
+ <version>${scalatest.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.googlecode.pojosr</groupId>
+ <artifactId>de.kalpatec.pojosr.framework</artifactId>
+ <version>${pojosr.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.tinybundles</groupId>
+ <artifactId>tinybundles</artifactId>
+ <version>${pax.tinybundle.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <!-- disable surefire -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ <skipTests>true</skipTests>
+ </configuration>
+ </plugin>
+ <!-- enable scalatest -->
+ <plugin>
+ <groupId>org.scalatest</groupId>
+ <artifactId>scalatest-maven-plugin</artifactId>
+ <version>1.0-M4-SNAP1</version>
+ <configuration>
+ <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
+ <junitxml>.</junitxml>
+ </configuration>
+ <executions>
+ <execution>
+ <id>test</id>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.scala-tools</groupId>
+ <artifactId>maven-scala-plugin</artifactId>
+ <version>2.15.2</version>
+ <executions>
+ <execution>
+ <id>compile</id>
+ <goals>
+ <goal>compile</goal>
+ <goal>testCompile</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+ <Import-Package>
+ akka*;version="[2.1,2.2)",
+ *
+ </Import-Package>
+ <Private-Package>org.apache.servicemix.akka.aries</Private-Package>
+ <Bundle-Description>${project.description}</Bundle-Description>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+
+</project>
Added: servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/resources/OSGI-INF/blueprint/akka-namespacehandler.xml
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/resources/OSGI-INF/blueprint/akka-namespacehandler.xml?rev=1458371&view=auto
==============================================================================
--- servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/resources/OSGI-INF/blueprint/akka-namespacehandler.xml (added)
+++ servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/resources/OSGI-INF/blueprint/akka-namespacehandler.xml Tue Mar 19 16:03:24 2013
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+ <!--
+ Register the namespace handler in the OSGi Service Registry
+ -->
+ <service interface="org.apache.aries.blueprint.NamespaceHandler">
+ <service-properties>
+ <entry key="osgi.service.blueprint.namespace">
+ <array>
+ <value>http://akka.io/xmlns/blueprint/v1.0.0</value>
+ </array>
+ </entry>
+ </service-properties>
+ <bean class="org.apache.servicemix.akka.aries.NamespaceHandler"/>
+ </service>
+
+</blueprint>
Added: servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/resources/org/apache/servicemix/akka/aries/akka.xsd
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/resources/org/apache/servicemix/akka/aries/akka.xsd?rev=1458371&view=auto
==============================================================================
--- servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/resources/org/apache/servicemix/akka/aries/akka.xsd (added)
+++ servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/resources/org/apache/servicemix/akka/aries/akka.xsd Tue Mar 19 16:03:24 2013
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns="http://akka.io/xmlns/blueprint/v1.0.0"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:bp="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ targetNamespace="http://akka.io/xmlns/blueprint/v1.0.0"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified">
+
+ <xsd:import namespace="http://www.osgi.org/xmlns/blueprint/v1.0.0"/>
+
+ <xsd:annotation>
+ <xsd:documentation>
+ Defines the configuration elements for setting up Akka with Blueprint
+ </xsd:documentation>
+ </xsd:annotation>
+
+ <xsd:element name="actor-system">
+ <xsd:complexType>
+ <xsd:annotation>
+ <xsd:documentation>
+ Defines an Akka ActorSystem
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:choice minOccurs="0" maxOccurs="unbounded">
+ <xsd:element ref="config" />
+ </xsd:choice>
+ </xsd:sequence>
+ <xsd:attribute name="id" type="xsd:ID"/>
+ <xsd:attribute name="name" type="xsd:string" use="optional"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="config" type="xsd:string">
+ <xsd:annotation>
+ <xsd:documentation>
+ Defines an Akka ActorSystem configuration
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+
+</xsd:schema>
Added: servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/scala/org/apache/servicemix/akka/aries/BlueprintActorSystemFactory.scala
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/scala/org/apache/servicemix/akka/aries/BlueprintActorSystemFactory.scala?rev=1458371&view=auto
==============================================================================
--- servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/scala/org/apache/servicemix/akka/aries/BlueprintActorSystemFactory.scala (added)
+++ servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/scala/org/apache/servicemix/akka/aries/BlueprintActorSystemFactory.scala Tue Mar 19 16:03:24 2013
@@ -0,0 +1,42 @@
+/**
+ * Copyright (C) 2009-2013 Typesafe Inc. <http://www.typesafe.com>
+ */
+package org.apache.servicemix.akka.aries
+
+import org.osgi.framework.BundleContext
+import akka.osgi.OsgiActorSystemFactory
+import akka.actor.ActorSystem
+import com.typesafe.config.{ Config, ConfigFactory }
+
+/**
+ * A set of helper/factory classes to build a Akka system using Blueprint. This class is only meant to be used by
+ * the [[akka.osgi.aries.blueprint.NamespaceHandler]] class, you should not use this class directly.
+ *
+ * If you're looking for a way to set up Akka using Blueprint without the namespace handler, you should use
+ * [[akka.osgi.OsgiActorSystemFactory]] instead.
+ */
+class BlueprintActorSystemFactory(context: BundleContext, name: String, fallbackClassLoader: Option[ClassLoader]) extends OsgiActorSystemFactory(context, fallbackClassLoader) {
+
+ def this(context: BundleContext, name: String) = this(context, name, Some(OsgiActorSystemFactory.akkaActorClassLoader))
+
+ var config: Option[String] = None
+
+ lazy val system: ActorSystem = super.createActorSystem(if (name == null || name.isEmpty) None else Some(name))
+
+ def setConfig(config: String): Unit = this.config = Some(config)
+
+ def create(): ActorSystem = system
+
+ def destroy(): Unit = system.shutdown()
+
+ /**
+ * Strategy method to create the Config for the ActorSystem, ensuring that the default/reference configuration is
+ * loaded from the akka-actor bundle.
+ */
+ override def actorSystemConfig(context: BundleContext): Config =
+ config match {
+ case Some(value) â ConfigFactory.parseString(value).withFallback(super.actorSystemConfig(context))
+ case None â super.actorSystemConfig(context)
+ }
+}
+
Added: servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/scala/org/apache/servicemix/akka/aries/NamespaceHandler.scala
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/scala/org/apache/servicemix/akka/aries/NamespaceHandler.scala?rev=1458371&view=auto
==============================================================================
--- servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/scala/org/apache/servicemix/akka/aries/NamespaceHandler.scala (added)
+++ servicemix/smx5/trunk/akka/akka-osgi-aries/src/main/scala/org/apache/servicemix/akka/aries/NamespaceHandler.scala Tue Mar 19 16:03:24 2013
@@ -0,0 +1,145 @@
+/**
+ * Copyright (C) 2009-2013 Typesafe Inc. <http://www.typesafe.com>
+ */
+package org.apache.servicemix.akka.aries
+
+import org.osgi.framework.BundleContext
+import org.osgi.service.blueprint.container.ComponentDefinitionException
+import org.osgi.service.blueprint.reflect._
+import org.apache.aries.blueprint.ParserContext
+import org.apache.aries.blueprint.mutable.{MutableRefMetadata, MutableValueMetadata, MutableBeanMetadata}
+import org.w3c.dom.{ Element, Node }
+import java.util.concurrent.atomic.AtomicInteger
+
+import akka.actor.ActorSystem
+import scala.annotation.tailrec
+import java.net.URL
+
+object NamespaceHandler {
+ private val ID_ATTRIBUTE = "id"
+ private val NAME_ATTRIBUTE = "name"
+
+ private val BUNDLE_CONTEXT_REFID = "blueprintBundleContext"
+
+ private val ACTORSYSTEM_ELEMENT_NAME = "actor-system"
+ private val CONFIG_ELEMENT_NAME = "config"
+
+ private val DESTROY_METHOD_NAME = "destroy"
+ private val FACTORY_METHOD_NAME = "create"
+}
+
+/**
+ * Aries Blueprint namespace handler implementation. This namespace handler will allow users of Apache Aries' Blueprint
+ * implementation to define their Akka [[akka.actor.ActorSystem]] using a syntax like this:
+ *
+ * {{{
+ * <?xml version="1.0" encoding="UTF-8"?>
+ * <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ * xmlns:akka="http://akka.io/xmlns/blueprint/v1.0.0">
+ *
+ * <akka:actor-system name="config">
+ * <akka:config>
+ * some.config {
+ * key=value
+ * }
+ * </akka:config>
+ * </akka:actor-system>
+ *
+ * </blueprint>
+ * }}}
+ *
+ * Users of other IoC frameworks in an OSGi environment should use [[akka.osgi.OsgiActorSystemFactory]] instead.
+ */
+class NamespaceHandler extends org.apache.aries.blueprint.NamespaceHandler {
+
+ import NamespaceHandler._
+
+ protected val idCounter = new AtomicInteger(0)
+
+ override def getSchemaLocation(namespace: String): URL = getClass().getResource("akka.xsd")
+
+ override def getManagedClasses = java.util.Collections.singleton(classOf[BlueprintActorSystemFactory])
+
+ override def parse(element: Element, context: ParserContext) =
+ if (element.getLocalName == ACTORSYSTEM_ELEMENT_NAME) parseActorSystem(element, context)
+ else throw new ComponentDefinitionException("Unexpected element for Akka namespace: %s".format(element))
+
+ override def decorate(node: Node, component: ComponentMetadata, context: ParserContext) =
+ throw new ComponentDefinitionException("Bad xml syntax: node decoration is not supported")
+
+ /*
+ * Parse <akka:actor-system/>
+ */
+ def parseActorSystem(element: Element, context: ParserContext) = {
+ val factory = createFactoryBean(context, element.getAttribute(NAME_ATTRIBUTE))
+
+ val nodelist = element.getChildNodes
+ (0 until nodelist.getLength) collect {
+ case idx if nodelist.item(idx).getNodeType == Node.ELEMENT_NODE â nodelist.item(idx).asInstanceOf[Element]
+ } foreach {
+ case child if child.getLocalName == CONFIG_ELEMENT_NAME â parseConfig(child, context, factory)
+ case child â throw new ComponentDefinitionException("Unexpected child element %s found in %s".format(child, element))
+ }
+
+ createActorSystemBean(context, element, factory)
+ }
+
+ /*
+ * Parse <akka:config/>
+ */
+ protected def parseConfig(node: Element, context: ParserContext, factory: MutableBeanMetadata) =
+ factory.addProperty(CONFIG_ELEMENT_NAME, createValue(context, node.getTextContent))
+
+
+ @tailrec protected final def findAvailableId(context: ParserContext): String =
+ ".akka-" + idCounter.incrementAndGet() match {
+ case id if context.getComponentDefinitionRegistry.containsComponentDefinition(id) â findAvailableId(context)
+ case available â available
+ }
+
+ /*
+ * Create the bean definition for the ActorSystem
+ */
+ protected def createActorSystemBean(context: ParserContext, element: Element, factory: MutableBeanMetadata): MutableBeanMetadata = {
+ val system = context.createMetadata(classOf[MutableBeanMetadata])
+ val id = if (element.hasAttribute(ID_ATTRIBUTE)) element.getAttribute(ID_ATTRIBUTE) else findAvailableId(context)
+
+ system.setId(id)
+ system.setFactoryComponent(factory)
+
+ system.setFactoryMethod(FACTORY_METHOD_NAME)
+ system.setRuntimeClass(classOf[ActorSystem])
+ system
+ }
+
+ /*
+ * Create the bean definition for the BlueprintActorSystemFactory
+ */
+ protected def createFactoryBean(context: ParserContext, name: String): MutableBeanMetadata = {
+ val factory = context.createMetadata(classOf[MutableBeanMetadata])
+ factory.setId(findAvailableId(context))
+ factory.setScope(BeanMetadata.SCOPE_SINGLETON)
+ factory.setProcessor(true)
+ factory.setRuntimeClass(classOf[BlueprintActorSystemFactory])
+
+ factory.setDestroyMethod(DESTROY_METHOD_NAME)
+
+ factory.addArgument(createRef(context, BUNDLE_CONTEXT_REFID), classOf[BundleContext].getName, -1)
+ factory.addArgument(createValue(context, name), classOf[String].getName, -1)
+ factory.setProcessor(true)
+ context.getComponentDefinitionRegistry.registerComponentDefinition(factory)
+ factory
+ }
+
+ def createValue(context: ParserContext, value: String) : ValueMetadata = {
+ val result = context.createMetadata(classOf[MutableValueMetadata])
+ result.setStringValue(value)
+ result
+ }
+
+ def createRef(context: ParserContext, componentId: String): RefMetadata = {
+ val result = context.createMetadata(classOf[MutableRefMetadata])
+ result.setComponentId(componentId)
+ result
+ }
+}
\ No newline at end of file
Added: servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/resources/log4j.properties?rev=1458371&view=auto
==============================================================================
--- servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/resources/log4j.properties (added)
+++ servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/resources/log4j.properties Tue Mar 19 16:03:24 2013
@@ -0,0 +1,33 @@
+#
+# 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.
+#
+
+#
+# The logging properties used during tests..
+#
+log4j.rootLogger=DEBUG, stdout
+
+# CONSOLE appender not used by default
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+# File appender
+log4j.appender.out=org.apache.log4j.FileAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.out.file=target/akka-camel.log
+log4j.appender.out.append=true
Added: servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/resources/org/apache/servicemix/akka/aries/config.xml
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/resources/org/apache/servicemix/akka/aries/config.xml?rev=1458371&view=auto
==============================================================================
--- servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/resources/org/apache/servicemix/akka/aries/config.xml (added)
+++ servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/resources/org/apache/servicemix/akka/aries/config.xml Tue Mar 19 16:03:24 2013
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:akka="http://akka.io/xmlns/blueprint/v1.0.0">
+
+ <service ref="system" interface="akka.actor.ActorSystem" />
+
+ <akka:actor-system id="system" name="config">
+ <akka:config>
+ some.config {
+ key=value
+ }
+ </akka:config>
+ </akka:actor-system>
+
+</blueprint>
Added: servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/resources/org/apache/servicemix/akka/aries/injection.xml
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/resources/org/apache/servicemix/akka/aries/injection.xml?rev=1458371&view=auto
==============================================================================
--- servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/resources/org/apache/servicemix/akka/aries/injection.xml (added)
+++ servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/resources/org/apache/servicemix/akka/aries/injection.xml Tue Mar 19 16:03:24 2013
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:akka="http://akka.io/xmlns/blueprint/v1.0.0">
+
+ <service interface="org.apache.servicemix.akka.aries.ActorSystemAwareBean">
+ <bean class="org.apache.servicemix.akka.aries.ActorSystemAwareBean">
+ <argument>
+ <akka:actor-system name="simple" />
+ </argument>
+ </bean>
+ </service>
+
+</blueprint>
Added: servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/resources/org/apache/servicemix/akka/aries/simple.xml
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/resources/org/apache/servicemix/akka/aries/simple.xml?rev=1458371&view=auto
==============================================================================
--- servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/resources/org/apache/servicemix/akka/aries/simple.xml (added)
+++ servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/resources/org/apache/servicemix/akka/aries/simple.xml Tue Mar 19 16:03:24 2013
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:akka="http://akka.io/xmlns/blueprint/v1.0.0">
+
+ <service ref="system" interface="akka.actor.ActorSystem" />
+
+ <akka:actor-system id="system" name="simple" />
+
+</blueprint>
Added: servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/scala/akka/osgi/PojoSRTestSupport.scala
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/scala/akka/osgi/PojoSRTestSupport.scala?rev=1458371&view=auto
==============================================================================
--- servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/scala/akka/osgi/PojoSRTestSupport.scala (added)
+++ servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/scala/akka/osgi/PojoSRTestSupport.scala Tue Mar 19 16:03:24 2013
@@ -0,0 +1,169 @@
+/**
+ * Copyright (C) 2009-2013 Typesafe Inc. <http://www.typesafe.com>
+ */
+package akka.osgi
+
+import de.kalpatec.pojosr.framework.launch.{ BundleDescriptor, PojoServiceRegistryFactory, ClasspathScanner }
+
+import scala.collection.JavaConversions.seqAsJavaList
+import scala.collection.JavaConversions.collectionAsScalaIterable
+import org.apache.commons.io.IOUtils.copy
+
+import org.osgi.framework._
+import java.net.URL
+import java.util.jar.JarInputStream
+import java.io._
+import org.scalatest.{ BeforeAndAfterAll, Suite }
+import java.util.{ UUID, Date, ServiceLoader, HashMap }
+import scala.reflect.ClassTag
+import scala.concurrent.duration._
+import scala.annotation.tailrec
+
+/**
+ * Trait that provides support for building akka-osgi tests using PojoSR
+ */
+trait PojoSRTestSupport extends Suite with BeforeAndAfterAll {
+
+ val MaxWaitDuration = 12800.millis
+ val SleepyTime = 50.millis
+
+ /**
+ * All bundles being found on the test classpath are automatically installed and started in the PojoSR runtime.
+ * Implement this to define the extra bundles that should be available for testing.
+ */
+ def testBundles: Seq[BundleDescriptor]
+
+ val bufferedLoadingErrors = new ByteArrayOutputStream()
+
+ lazy val context: BundleContext = {
+ val config = new HashMap[String, AnyRef]()
+ System.setProperty("org.osgi.framework.storage", "target/akka-osgi/" + UUID.randomUUID().toString)
+
+ val bundles = new ClasspathScanner().scanForBundles()
+ bundles.addAll(testBundles)
+ config.put(PojoServiceRegistryFactory.BUNDLE_DESCRIPTORS, bundles)
+
+ val oldErr = System.err
+ System.setErr(new PrintStream(bufferedLoadingErrors))
+ try {
+ ServiceLoader.load(classOf[PojoServiceRegistryFactory]).iterator.next.newPojoServiceRegistry(config).getBundleContext
+ } catch {
+ case e: Throwable â oldErr.write(bufferedLoadingErrors.toByteArray); throw e
+ } finally {
+ System.setErr(oldErr)
+ }
+ }
+
+ // Ensure bundles get stopped at the end of the test to release resources and stop threads
+ override protected def afterAll() = context.getBundles.foreach(_.stop)
+
+ /**
+ * Convenience method to find a bundle by symbolic name
+ */
+ def bundleForName(name: String) =
+ context.getBundles.find(_.getSymbolicName == name).getOrElse(fail("Unable to find bundle with symbolic name %s".format(name)))
+
+ /**
+ * Convenience method to find a service by interface. If the service is not already available in the OSGi Service
+ * Registry, this method will wait for a few seconds for the service to appear.
+ */
+ def serviceForType[T](implicit t: ClassTag[T]): T =
+ context.getService(awaitReference(t.runtimeClass)).asInstanceOf[T]
+
+ def awaitReference[T](serviceType: Class[T]): ServiceReference[T] = awaitReference(serviceType, SleepyTime)
+
+ def awaitReference[T](serviceType: Class[T], wait: FiniteDuration): ServiceReference[T] = {
+
+ @tailrec def poll(step: Duration, deadline: Deadline): ServiceReference[T] = context.getServiceReference(serviceType) match {
+ case null â
+ if (deadline.isOverdue()) fail("Gave up waiting for service of type %s".format(serviceType))
+ else {
+ Thread.sleep((step min deadline.timeLeft max Duration.Zero).toMillis)
+ poll(step, deadline)
+ }
+ case some â some
+ }
+
+ poll(wait, Deadline.now + MaxWaitDuration)
+ }
+
+ protected def buildTestBundles(builders: Seq[BundleDescriptorBuilder]): Seq[BundleDescriptor] = builders map (_.build)
+
+ def filterErrors()(block: â Unit): Unit = {
+ try {
+ block
+ } catch {
+ case e: Throwable â System.err.write(bufferedLoadingErrors.toByteArray); throw e
+ }
+ }
+}
+
+object PojoSRTestSupport {
+ /**
+ * Convenience method to define additional test bundles
+ */
+ def bundle(name: String) = new BundleDescriptorBuilder(name)
+}
+
+/**
+ * Helper class to make it easier to define test bundles
+ */
+class BundleDescriptorBuilder(name: String) {
+
+ import org.ops4j.pax.tinybundles.core.TinyBundles
+
+ val tinybundle = TinyBundles.bundle.set(Constants.BUNDLE_SYMBOLICNAME, name)
+
+ /**
+ * Add a Blueprint XML file to our test bundle
+ */
+ def withBlueprintFile(name: String, contents: URL): BundleDescriptorBuilder = {
+ tinybundle.add("OSGI-INF/blueprint/%s".format(name), contents)
+ this
+ }
+
+ /**
+ * Add a Blueprint XML file to our test bundle
+ */
+ def withBlueprintFile(contents: URL): BundleDescriptorBuilder = {
+ val filename = contents.getFile.split("/").last
+ withBlueprintFile(filename, contents)
+ }
+
+ /**
+ * Add a Bundle activator to our test bundle
+ */
+ def withActivator(activator: Class[_ <: BundleActivator]): BundleDescriptorBuilder = {
+ tinybundle.set(Constants.BUNDLE_ACTIVATOR, activator.getName)
+ this
+ }
+
+ /**
+ * Build the actual PojoSR BundleDescriptor instance
+ */
+ def build: BundleDescriptor = {
+ val file: File = tinybundleToJarFile(name)
+ new BundleDescriptor(getClass().getClassLoader(), new URL("jar:" + file.toURI().toString() + "!/"), extractHeaders(file))
+ }
+
+ def extractHeaders(file: File): HashMap[String, String] = {
+ val headers = new HashMap[String, String]()
+
+ val jis = new JarInputStream(new FileInputStream(file))
+ try {
+ for (entry â jis.getManifest().getMainAttributes().entrySet())
+ headers.put(entry.getKey().toString(), entry.getValue().toString())
+ } finally jis.close()
+
+ headers
+ }
+
+ def tinybundleToJarFile(name: String): File = {
+ val file = new File("target/%s-%tQ.jar".format(name, new Date()))
+ val fos = new FileOutputStream(file)
+ try copy(tinybundle.build(), fos) finally fos.close()
+
+ file
+ }
+}
+
Added: servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/scala/org/apache/servicemix/akka/aries/ActorSystemAwareBean.scala
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/scala/org/apache/servicemix/akka/aries/ActorSystemAwareBean.scala?rev=1458371&view=auto
==============================================================================
--- servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/scala/org/apache/servicemix/akka/aries/ActorSystemAwareBean.scala (added)
+++ servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/scala/org/apache/servicemix/akka/aries/ActorSystemAwareBean.scala Tue Mar 19 16:03:24 2013
@@ -0,0 +1,14 @@
+/**
+ * Copyright (C) 2009-2013 Typesafe Inc. <http://www.typesafe.com>
+ */
+package org.apache.servicemix.akka.aries
+
+import akka.actor.ActorSystem
+
+/**
+ * Just a simple POJO that can contain an actor system.
+ * Used for testing dependency injection with Blueprint
+ */
+class ActorSystemAwareBean(val system: ActorSystem) {
+
+}
Added: servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/scala/org/apache/servicemix/akka/aries/NamespaceHandlerTest.scala
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/scala/org/apache/servicemix/akka/aries/NamespaceHandlerTest.scala?rev=1458371&view=auto
==============================================================================
--- servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/scala/org/apache/servicemix/akka/aries/NamespaceHandlerTest.scala (added)
+++ servicemix/smx5/trunk/akka/akka-osgi-aries/src/test/scala/org/apache/servicemix/akka/aries/NamespaceHandlerTest.scala Tue Mar 19 16:03:24 2013
@@ -0,0 +1,113 @@
+/**
+ * Copyright (C) 2009-2013 Typesafe Inc. <http://www.typesafe.com>
+ */
+package org.apache.servicemix.akka.aries
+
+import org.scalatest.{Ignore, WordSpec}
+import akka.actor.ActorSystem
+import de.kalpatec.pojosr.framework.launch.BundleDescriptor
+import akka.osgi.PojoSRTestSupport
+import akka.osgi.PojoSRTestSupport.bundle
+import org.scalatest.matchers.MustMatchers
+
+/**
+ * Test cases for {@link ActorSystemActivator}
+ */
+@Ignore
+object NamespaceHandlerTest {
+
+ /*
+ * Bundle-SymbolicName to easily find our test bundle
+ */
+ val TEST_BUNDLE_NAME = "akka.osgi.test.aries.namespace"
+
+ /*
+ * Bundle descriptor representing the akka-osgi bundle itself
+ */
+ val AKKA_OSGI_BLUEPRINT =
+ bundle("akka-osgi").withBlueprintFile(getClass.getResource("/OSGI-INF/blueprint/akka-namespacehandler.xml"))
+
+}
+
+class SimpleNamespaceHandlerTest extends WordSpec with MustMatchers with PojoSRTestSupport {
+
+ import NamespaceHandlerTest._
+
+ val testBundles: Seq[BundleDescriptor] = buildTestBundles(Seq(
+ AKKA_OSGI_BLUEPRINT,
+ bundle(TEST_BUNDLE_NAME).withBlueprintFile(getClass.getResource("simple.xml"))))
+
+ "simple.xml" must {
+ "set up ActorSystem when bundle starts" in {
+ filterErrors() {
+ serviceForType[ActorSystem] must not be (null)
+ }
+ }
+
+ "stop the ActorSystem when bundle stops" in {
+ filterErrors() {
+ val system = serviceForType[ActorSystem]
+ system.isTerminated must be(false)
+
+ bundleForName(TEST_BUNDLE_NAME).stop()
+
+ system.awaitTermination()
+ system.isTerminated must be(true)
+ }
+ }
+ }
+
+}
+
+class ConfigNamespaceHandlerTest extends WordSpec with MustMatchers with PojoSRTestSupport {
+
+ import NamespaceHandlerTest._
+
+ val testBundles: Seq[BundleDescriptor] = buildTestBundles(Seq(
+ AKKA_OSGI_BLUEPRINT,
+ bundle(TEST_BUNDLE_NAME).withBlueprintFile(getClass.getResource("config.xml"))))
+
+ "config.xml" must {
+ "set up ActorSystem when bundle starts" in {
+ filterErrors() {
+ val system = serviceForType[ActorSystem]
+ system must not be (null)
+ system.settings.config.getString("some.config.key") must be("value")
+ }
+ }
+
+ "stop the ActorSystem when bundle stops" in {
+ filterErrors() {
+ val system = serviceForType[ActorSystem]
+ system.isTerminated must be(false)
+
+ bundleForName(TEST_BUNDLE_NAME).stop()
+
+ system.awaitTermination()
+ system.isTerminated must be(true)
+ }
+ }
+ }
+
+}
+
+class DependencyInjectionNamespaceHandlerTest extends WordSpec with MustMatchers with PojoSRTestSupport {
+
+ import NamespaceHandlerTest._
+
+ val testBundles: Seq[BundleDescriptor] = buildTestBundles(Seq(
+ AKKA_OSGI_BLUEPRINT,
+ bundle(TEST_BUNDLE_NAME).withBlueprintFile(getClass.getResource("injection.xml"))))
+
+ "injection.xml" must {
+
+ "set up bean containing ActorSystem" in {
+ filterErrors() {
+ val bean = serviceForType[ActorSystemAwareBean]
+ bean must not be (null)
+ bean.system must not be (null)
+ }
+ }
+ }
+
+}
Copied: servicemix/smx5/trunk/akka/pom.xml (from r1458369, servicemix/smx5/trunk/examples/pom.xml)
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/akka/pom.xml?p2=servicemix/smx5/trunk/akka/pom.xml&p1=servicemix/smx5/trunk/examples/pom.xml&r1=1458369&r2=1458371&rev=1458371&view=diff
==============================================================================
--- servicemix/smx5/trunk/examples/pom.xml (original)
+++ servicemix/smx5/trunk/akka/pom.xml Tue Mar 19 16:03:24 2013
@@ -2,7 +2,7 @@
<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">
<!--
-
+
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.
@@ -28,17 +28,13 @@
<relativePath>../parent/pom.xml</relativePath>
</parent>
- <groupId>org.apache.servicemix.examples</groupId>
- <artifactId>examples</artifactId>
+ <groupId>org.apache.servicemix.akka</groupId>
+ <artifactId>akka</artifactId>
<packaging>pom</packaging>
- <name>Apache ServiceMix :: Examples</name>
+ <name>Apache ServiceMix :: Akka Support</name>
<modules>
- <module>activemq</module>
- <module>activiti</module>
- <!-- <module>akka</module> commented out now until Akka OSGi bundle are available in a repo -->
- <module>camel</module>
- <module>cxf</module>
+ <module>akka-osgi-aries</module>
</modules>
</project>
Modified: servicemix/smx5/trunk/assemblies/apache-servicemix/src/main/filtered-resources/features.xml
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/assemblies/apache-servicemix/src/main/filtered-resources/features.xml?rev=1458371&r1=1458370&r2=1458371&view=diff
==============================================================================
--- servicemix/smx5/trunk/assemblies/apache-servicemix/src/main/filtered-resources/features.xml (original)
+++ servicemix/smx5/trunk/assemblies/apache-servicemix/src/main/filtered-resources/features.xml Tue Mar 19 16:03:24 2013
@@ -114,6 +114,12 @@
<bundle>mvn:org.apache.servicemix.examples/activiti-camel/${version}</bundle>
</feature>
+ <feature name="examples-akka-camel" version="${version}" resolver="(obr)">
+ <feature version="${akka.version}">akka</feature>
+ <feature version="${camel.version}">camel-scala</feature>
+ <bundle>mvn:org.apache.servicemix.examples/akka-camel/${version}</bundle>
+ </feature>
+
<!-- Add a feature called 'activemq' because CXF seems to expect that instead of 'activemq-broker' -->
<feature name="activemq" version="${activemq.version}">
<feature version="${activemq.version}">activemq-broker</feature>
@@ -182,4 +188,18 @@
<bundle>mvn:org.apache.servicemix.activiti/org.apache.servicemix.activiti.config/${project.version}</bundle>
</feature>
+ <!-- Akka support -->
+ <feature name="akka" version="${akka.version}" resolver="(obr)">
+ <bundle dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.scala-library/${scala.bundle.version}</bundle>
+ <bundle dependency="true">mvn:com.typesafe/config/${typesafe-config.version}</bundle>
+ <bundle>mvn:com.typesafe.akka/akka-actor_2.10/${akka.version}</bundle>
+ <bundle>mvn:com.typesafe.akka/akka-camel_2.10/${akka.version}</bundle>
+ <bundle>mvn:com.typesafe.akka/akka-osgi_2.10/${akka.version}</bundle>
+ <!--
+ Replace Akka's akka-osgi-aries with our own version to be compatible with Aries Blueprint 1.0.x
+ <bundle>mvn:com.typesafe.akka/akka-osgi-aries_2.10/${akka.version}</bundle>
+ -->
+ <bundle>mvn:org.apache.servicemix.akka/org.apache.servicemix.akka.akka-osgi-aries/${project.version}</bundle>
+ </feature>
+
</features>
Modified: servicemix/smx5/trunk/assemblies/shared/src/main/filtered-resources/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/assemblies/shared/src/main/filtered-resources/pom.xml?rev=1458371&r1=1458370&r2=1458371&view=diff
==============================================================================
--- servicemix/smx5/trunk/assemblies/shared/src/main/filtered-resources/pom.xml (original)
+++ servicemix/smx5/trunk/assemblies/shared/src/main/filtered-resources/pom.xml Tue Mar 19 16:03:24 2013
@@ -35,6 +35,7 @@
<modules>
<module>activemq</module>
<module>activiti</module>
+ <module>akka</module>
<module>camel</module>
<module>cxf</module>
<module>karaf</module>
Modified: servicemix/smx5/trunk/assemblies/shared/src/main/resources/examples-unix-bin.xml
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/assemblies/shared/src/main/resources/examples-unix-bin.xml?rev=1458371&r1=1458370&r2=1458371&view=diff
==============================================================================
--- servicemix/smx5/trunk/assemblies/shared/src/main/resources/examples-unix-bin.xml (original)
+++ servicemix/smx5/trunk/assemblies/shared/src/main/resources/examples-unix-bin.xml Tue Mar 19 16:03:24 2013
@@ -32,6 +32,7 @@
<includes>
<include>activemq/**</include>
<include>activiti/**</include>
+ <include>akka/**</include>
<include>camel/**</include>
<include>cxf/**</include>
</includes>
@@ -58,6 +59,7 @@
<include>README.txt</include>
<include>activemq/**/README.txt</include>
<include>activiti/**/README.txt</include>
+ <include>akka/**/README.txt</include>
<include>camel/**/README.txt</include>
<include>cxf/**/README.txt</include>
</includes>
Modified: servicemix/smx5/trunk/assemblies/shared/src/main/resources/examples-windows-bin.xml
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/assemblies/shared/src/main/resources/examples-windows-bin.xml?rev=1458371&r1=1458370&r2=1458371&view=diff
==============================================================================
--- servicemix/smx5/trunk/assemblies/shared/src/main/resources/examples-windows-bin.xml (original)
+++ servicemix/smx5/trunk/assemblies/shared/src/main/resources/examples-windows-bin.xml Tue Mar 19 16:03:24 2013
@@ -32,6 +32,7 @@
<includes>
<include>activemq/**</include>
<include>activiti/**</include>
+ <include>akka/**</include>
<include>camel/**</include>
<include>cxf/**</include>
</includes>
@@ -58,6 +59,7 @@
<include>README.txt</include>
<include>activemq/**/README.txt</include>
<include>activiti/**/README.txt</include>
+ <include>akka/**/README.txt</include>
<include>camel/**/README.txt</include>
<include>cxf/**/README.txt</include>
</includes>
Modified: servicemix/smx5/trunk/examples/akka/akka-camel/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/akka/akka-camel/pom.xml?rev=1458371&r1=1458370&r2=1458371&view=diff
==============================================================================
--- servicemix/smx5/trunk/examples/akka/akka-camel/pom.xml (original)
+++ servicemix/smx5/trunk/examples/akka/akka-camel/pom.xml Tue Mar 19 16:03:24 2013
@@ -4,7 +4,7 @@
<parent>
<artifactId>akka-examples</artifactId>
<groupId>org.apache.servicemix.examples</groupId>
- <version>4.5.0-SNAPSHOT</version>
+ <version>5.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -14,9 +14,7 @@
<packaging>bundle</packaging>
<properties>
- <akka.version>2.1-SNAPSHOT</akka.version>
<maven-scala-plugin.version>2.15.2</maven-scala-plugin.version>
- <scala.version>2.9.1</scala.version>
</properties>
<dependencies>
@@ -27,18 +25,18 @@
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
- <artifactId>akka-actor</artifactId>
+ <artifactId>akka-actor_2.10</artifactId>
<version>${akka.version}</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
- <artifactId>akka-osgi</artifactId>
- <version>2.1-SNAPSHOT</version>
+ <artifactId>akka-osgi_2.10</artifactId>
+ <version>${akka.version}</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
- <artifactId>akka-camel</artifactId>
- <version>2.1-SNAPSHOT</version>
+ <artifactId>akka-camel_2.10</artifactId>
+ <version>${akka.version}</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
@@ -47,12 +45,10 @@
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-scala</artifactId>
- <version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test</artifactId>
- <version>${camel.version}</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -107,8 +103,9 @@
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Description>${project.description}</Bundle-Description>
- <Import-Package>akka.osgi.blueprint,org.osgi.framework,akka.event,*</Import-Package>
+ <Import-Package>org.osgi.framework,akka.event,*</Import-Package>
<Export-Package>org.apache.servicemix.examples.akka</Export-Package>
+ <Require-Bundle>com.typesafe.akka.camel</Require-Bundle>
</instructions>
</configuration>
</plugin>
Modified: servicemix/smx5/trunk/examples/akka/akka-camel/src/main/resources/application.conf
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/akka/akka-camel/src/main/resources/application.conf?rev=1458371&r1=1458370&r2=1458371&view=diff
==============================================================================
--- servicemix/smx5/trunk/examples/akka/akka-camel/src/main/resources/application.conf (original)
+++ servicemix/smx5/trunk/examples/akka/akka-camel/src/main/resources/application.conf Tue Mar 19 16:03:24 2013
@@ -1,5 +1,38 @@
-akka.actor.deployment {
+akka {
+ actor.deployment {
# there's no extra configuration here at the moment, but you could
# configure routers, log levels, ... or whatever settings you need
# for your own application
+
+ }
+
+ # This is a copy of the akka-camel reference.conf
+ # TODO: work out a better solution (extender to load configs from reference.conf into the OSGi Service Registry)
+ camel {
+ # Whether JMX should be enabled or disabled for the Camel Context
+ jmx = off
+ # enable/disable streaming cache on the Camel Context
+ streamingCache = on
+ consumer {
+ # Configured setting which determines whether one-way communications
+ # between an endpoint and this consumer actor
+ # should be auto-acknowledged or application-acknowledged.
+ # This flag has only effect when exchange is in-only.
+ auto-ack = on
+
+ # When endpoint is out-capable (can produce responses) reply-timeout is the
+ # maximum time the endpoint can take to send the response before the message
+ # exchange fails. This setting is used for out-capable, in-only,
+ # manually acknowledged communication
+ reply-timeout = 1m
+
+ # The duration of time to await activation of an endpoint.
+ activation-timeout = 10s
+ }
+
+ #Scheme to FQCN mappings for CamelMessage body conversions
+ conversions {
+ "file" = "java.io.InputStream"
+ }
+ }
}
\ No newline at end of file
Modified: servicemix/smx5/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/examples/akka/CamelBridge.scala
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/examples/akka/CamelBridge.scala?rev=1458371&r1=1458370&r2=1458371&view=diff
==============================================================================
--- servicemix/smx5/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/examples/akka/CamelBridge.scala (original)
+++ servicemix/smx5/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/examples/akka/CamelBridge.scala Tue Mar 19 16:03:24 2013
@@ -20,7 +20,7 @@ import akka.actor.{Props, Actor, ActorRe
import akka.camel._
import io.Source
import org.apache.servicemix.examples.akka.Stats.{Input, Report}
-import akka.util.duration._
+import scala.concurrent.duration._
/**
* Sets up the actors that bridge between the Camel routes and the
@@ -36,6 +36,7 @@ object CamelBridge {
system.actorOf(Props(new CamelConsumer(stats)), "camel.consumer")
val producer = system.actorOf(Props[CamelProducer])
+ import system.dispatcher
system.scheduler.schedule(5 seconds, 30 seconds) {
stats.tell(Report(), producer)
}
Modified: servicemix/smx5/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/examples/akka/Stats.scala
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/examples/akka/Stats.scala?rev=1458371&r1=1458370&r2=1458371&view=diff
==============================================================================
--- servicemix/smx5/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/examples/akka/Stats.scala (original)
+++ servicemix/smx5/trunk/examples/akka/akka-camel/src/main/scala/org/apache/servicemix/examples/akka/Stats.scala Tue Mar 19 16:03:24 2013
@@ -19,7 +19,7 @@ package org.apache.servicemix.examples.a
import akka.actor.{ActorRef, Actor, Props, ActorSystem}
import akka.pattern._
import akka.util.Timeout
-import akka.util.duration._
+import scala.concurrent.duration._
import collection.mutable.Map
import collection.SortedSet
import org.apache.servicemix.examples.akka.Stats.Metric
@@ -112,6 +112,8 @@ class StdDev(val average: ActorRef) exte
def receive = {
case (key: String, items: Seq[Int]) if items.size > 1 =>
val original = sender
+
+ import context.dispatcher
ask(average, items).onSuccess {
case avg : Double => {
ask(sum_of_squares, (items, avg)).onSuccess {
Modified: servicemix/smx5/trunk/examples/akka/akka-camel/src/test/scala/org/apache/servicemix/examples/akka/StatsTest.scala
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/akka/akka-camel/src/test/scala/org/apache/servicemix/examples/akka/StatsTest.scala?rev=1458371&r1=1458370&r2=1458371&view=diff
==============================================================================
--- servicemix/smx5/trunk/examples/akka/akka-camel/src/test/scala/org/apache/servicemix/examples/akka/StatsTest.scala (original)
+++ servicemix/smx5/trunk/examples/akka/akka-camel/src/test/scala/org/apache/servicemix/examples/akka/StatsTest.scala Tue Mar 19 16:03:24 2013
@@ -21,8 +21,8 @@ import org.junit.Assert.fail
import akka.actor.ActorSystem
import akka.pattern._
import akka.util.Timeout
-import akka.util.duration._
-import akka.dispatch.Await
+import scala.concurrent.duration._
+import scala.concurrent.Await
import org.apache.servicemix.examples.akka.Stats.{Input, Report}
import java.util.concurrent.TimeoutException
Modified: servicemix/smx5/trunk/examples/akka/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/akka/pom.xml?rev=1458371&r1=1458370&r2=1458371&view=diff
==============================================================================
--- servicemix/smx5/trunk/examples/akka/pom.xml (original)
+++ servicemix/smx5/trunk/examples/akka/pom.xml Tue Mar 19 16:03:24 2013
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.servicemix.examples</groupId>
<artifactId>examples</artifactId>
- <version>4.5.0-SNAPSHOT</version>
+ <version>5.0.0-SNAPSHOT</version>
</parent>
<groupId>org.apache.servicemix.examples</groupId>
Modified: servicemix/smx5/trunk/examples/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/pom.xml?rev=1458371&r1=1458370&r2=1458371&view=diff
==============================================================================
--- servicemix/smx5/trunk/examples/pom.xml (original)
+++ servicemix/smx5/trunk/examples/pom.xml Tue Mar 19 16:03:24 2013
@@ -36,7 +36,7 @@
<modules>
<module>activemq</module>
<module>activiti</module>
- <!-- <module>akka</module> commented out now until Akka OSGi bundle are available in a repo -->
+ <module>akka</module>
<module>camel</module>
<module>cxf</module>
</modules>
Modified: servicemix/smx5/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/parent/pom.xml?rev=1458371&r1=1458370&r2=1458371&view=diff
==============================================================================
--- servicemix/smx5/trunk/parent/pom.xml (original)
+++ servicemix/smx5/trunk/parent/pom.xml Tue Mar 19 16:03:24 2013
@@ -48,6 +48,11 @@
<aries.version>1.0.0</aries.version>
<aries.transaction.version>1.0.0</aries.transaction.version>
<pax.logging.version>1.7.0</pax.logging.version>
+
+ <akka.version>2.1.2</akka.version>
+ <scala.version>2.10.0</scala.version>
+ <typesafe-config.version>1.0.0</typesafe-config.version>
+
<servicemix.specs.version>2.2.0</servicemix.specs.version>
</properties>
Modified: servicemix/smx5/trunk/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/pom.xml?rev=1458371&r1=1458370&r2=1458371&view=diff
==============================================================================
--- servicemix/smx5/trunk/pom.xml (original)
+++ servicemix/smx5/trunk/pom.xml Tue Mar 19 16:03:24 2013
@@ -38,6 +38,7 @@
<modules>
<module>parent</module>
<module>activiti</module>
+ <module>akka</module>
<module>branding</module>
<module>logging</module>
<module>examples</module>
@@ -184,6 +185,7 @@
<rhino.bundle.version>1.7R1_3</rhino.bundle.version>
<saaj-impl.bundle.version>1.3.9_2</saaj-impl.bundle.version>
<saxon.bundle.version>9.3.0.11_2</saxon.bundle.version>
+ <scala.bundle.version>2.10.0_1</scala.bundle.version>
<snmp4j.bundle.version>1.8.1_4</snmp4j.bundle.version>
<velocity.bundle.version>1.7_5</velocity.bundle.version>
<wsdl4j.bundle.version>1.6.2_3</wsdl4j.bundle.version>
@@ -227,8 +229,11 @@
<joda-time.version>1.6.2</joda-time.version>
<lingo.version>1.3</lingo.version>
<mybatis.version>3.1.1</mybatis.version>
- <scala.version>2.10.0</scala.version>
+ <pax.tinybundle.version>1.0.0</pax.tinybundle.version>
+ <pojosr.version>0.2.1</pojosr.version>
+ <scalatest.version>1.9.1</scalatest.version>
<scriptengines.version>1.1</scriptengines.version>
+ <slf4j.version>1.6.6</slf4j.version>
<spring.version>3.0.7.RELEASE</spring.version>
<spring.osgi.version>1.2.1</spring.osgi.version>
<wss4j.version>1.6.7</wss4j.version>