`
a3mao
  • 浏览: 562877 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Apache Servicemix 学习(3) ------ 创建service unit

阅读更多
ServiceMix提供了几个默认的mavne命令,可以方便的开发出servicemix工程。比如:用servicemix-service-unit来创建一个service unit工程。servicemix提供的几个内置命令列表:
servicemix-binding-component
servicemix-service-assembly 
servicemix-service-engine 
servicemix-service-unit 
servicemix-shared-library
servicemix-bean-service-unit
servicemix-camel-service-unit
servicemix-cxf-bc-consumer-service-unit
servicemix-cxf-bc-provider-service-unit
servicemix-cxf-se-service-unit
servicemix-drools-service-unit
servicemix-eip-service-unit
servicemix-exec-service-unit
servicemix-file-poller-service-unit
servicemix-file-sender-service-unit
servicemix-ftp-poller-service-unit
servicemix-ftp-sender-service-unit
servicemix-http-consumer-service-unit
servicemix-http-soap-consumer-service-unit
servicemix-http-provider-service-unit
servicemix-http-soap-provider-service-unit
servicemix-jms-consumer-service-unit
servicemix-jms-soap-consumer-service-unit
servicemix-jms-jca-consumer-service-unit
servicemix-jms-provider-service-unit	
servicemix-jms-soap-provider-service-unit
servicemix-jsr181-annotated-service-unit
servicemix-jsr181-wsdl-first-service-unit
servicemix-lwcontainer-service-unit
servicemix-mail-poller-service-unit
servicemix-mail-sender-service-unit
servicemix-ode-service-unit
servicemix-osworkflow-service-unit
servicemix-quartz-cron-trigger-service-unit
servicemix-quartz-simple-trigger-service-unit
servicemix-quartz-custom-marshaler-service-unit
servicemix-saxon-xquery-service-unit
servicemix-saxon-xslt-service-unit
servicemix-script-service-unit
servicemix-scripting-service-unit
servicemix-smpp-consumer-service-unit
servicemix-smpp-provider-service-unit
servicemix-snmp-poller-service-unit
servicemix-snmp-trap-consumer-service-unit
servicemix-validation-service-unit
servicemix-vfs-poller-service-unit
servicemix-vfs-sender-service-unit


在工程目录(/opt/ericWorkspace/servicemix )下运行命令:
mvn archetype:create -DarchetypeArtifactId=servicemix-service-unit -DarchetypeGroupId=org.apache.servicemix.tooling -DartifactId=tutorial-file-su


如果出现如下信息:
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Tutorial
[INFO]    task-segment: [archetype:create] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [archetype:create {execution: default-cli}]
[WARNING] This goal is deprecated. Please use mvn archetype:generate instead
[INFO] Defaulting package to group ID: org.apache.servicemix.tutorial
[INFO] artifact org.apache.servicemix.tooling:servicemix-service-unit: checking for updates from central
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating OldArchetype: servicemix-service-unit:RELEASE
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: org.apache.servicemix.tutorial
[INFO] Parameter: packageName, Value: org.apache.servicemix.tutorial
[INFO] Parameter: package, Value: org.apache.servicemix.tutorial
[INFO] Parameter: artifactId, Value: tutorial-file-su
[INFO] Parameter: basedir, Value: /opt/ericWorkspace/servicemix
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] ********************* End of debug info from resources from generated POM ***********************
[INFO] OldArchetype created in dir: /opt/ericWorkspace/servicemix/tutorial-file-su
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3 seconds
[INFO] Finished at: Mon Aug 16 20:49:27 CST 2010
[INFO] Final Memory: 11M/130M
[INFO] ------------------------------------------------------------------------
eric@eric-laptop:/opt/ericWorkspace/servicemix$ 



则说明创建service unit成功。
在工程目录(servicemix)下会生成tutorial-file-su子模块。
tutorial-file-su子模块目录结构:

tutorial-file-su
                pom.xml
                src
                   main
                       resources

修改pom.xml文件,将name改为 Tutorial :: File SU

<project>
  ...
  <name>Tutorial :: File SU</name>
  ...
</project>



同时。增加一个依赖类包:
<dependency>
    <groupId>org.apache.servicemix</groupId>
    <artifactId>servicemix-file</artifactId>
    <version>${servicemix-version}</version>
  </dependency>


整个pom文件内容:
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <artifactId>parent</artifactId>
    <groupId>org.apache.servicemix.tutorial</groupId>
    <version>1.0-SNAPSHOT</version>
  </parent>
  <groupId>org.apache.servicemix.tutorial</groupId>
  <artifactId>tutorial-file-su</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jbi-service-unit</packaging>
  <name>Tutorial :: File SU</name>
  <url>http://www.myorganization.org</url>
  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <includes>
          <include>**/*</include>
        </includes>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <groupId>org.apache.servicemix.tooling</groupId>
        <artifactId>jbi-maven-plugin</artifactId>
        <version>${servicemix-version}</version>
        <extensions>true</extensions>
      </plugin>
    </plugins>
  </build>
  <repositories>
    <repository>
      <releases />
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>apache</id>
      <name>Apache Repository</name>
      <url>http://people.apache.org/repo/m2-ibiblio-rsync-repository</url>
    </repository>
    <repository>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots />
      <id>apache.snapshots</id>
      <name>Apache Snapshots Repository</name>
      <url>http://people.apache.org/repo/m2-snapshot-repository</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <releases />
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>apache</id>
      <name>Apache Repository</name>
      <url>http://people.apache.org/repo/m2-ibiblio-rsync-repository</url>
    </pluginRepository>
    <pluginRepository>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots />
      <id>apache.snapshots</id>
      <name>Apache Snapshots Repository</name>
      <url>http://people.apache.org/repo/m2-snapshot-repository</url>
    </pluginRepository>
  </pluginRepositories>
  <dependencies>
  <dependency>
    <groupId>org.apache.servicemix</groupId>
    <artifactId>servicemix-file</artifactId>
    <version>${servicemix-version}</version>
  </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <properties>
    <servicemix-version>3.2.3</servicemix-version>
  </properties>
</project>


这只是一个非常简单的service unit工程,并没有java代码,只是利用了servicemix内置的service unit,如果能够让servicemix支持service unit,那么我就要写xbean.xml配置文件,将其配置到servicemix中。

在tutorial-file-su/src/main/resources目录下新建xbean.xml文件,内容为:
<beans xmlns:file="http://servicemix.apache.org/file/1.0"
	xmlns:tut="urn:servicemix2:tutorial2">
	
	<file:sender service="tut:file" 
             endpoint="sender"
             directory="file:/home/eric/temp/sender" />

	<file:poller service="tut:file" 
             endpoint="poller"
             file="file:/home/eric/temp/poller" 
             targetService="tut:file"
             targetEndpoint="tut:wiretap"/>
</beans>


此外,我们还要创建 service assembly工程,
输入命令:
mvn archetype:create -DarchetypeArtifactId=servicemix-service-assembly -DarchetypeGroupId=org.apache.servicemix.tooling -DartifactId=tutorial-sa


当出现如下信息时
[INFO] ------------------------------------------------------------------------
[INFO] Building Tutorial
[INFO]    task-segment: [archetype:create] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [archetype:create {execution: default-cli}]
[WARNING] This goal is deprecated. Please use mvn archetype:generate instead
[INFO] Defaulting package to group ID: org.apache.servicemix.tutorial
[INFO] artifact org.apache.servicemix.tooling:servicemix-service-assembly: checking for updates from central
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating OldArchetype: servicemix-service-assembly:RELEASE
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: org.apache.servicemix.tutorial
[INFO] Parameter: packageName, Value: org.apache.servicemix.tutorial
[INFO] Parameter: package, Value: org.apache.servicemix.tutorial
[INFO] Parameter: artifactId, Value: tutorial-sa
[INFO] Parameter: basedir, Value: /opt/ericWorkspace/servicemix
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] ********************* End of debug info from resources from generated POM ***********************
[INFO] OldArchetype created in dir: /opt/ericWorkspace/servicemix/tutorial-sa
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6 seconds
[INFO] Finished at: Mon Aug 16 21:16:12 CST 2010
[INFO] Final Memory: 22M/268M
[INFO] ------------------------------------------------------------------------


此时,sa工程创建成功,
sa子模块目录结构为:

tutorial-sa
           pom.xml

修改pom,xml
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <artifactId>parent</artifactId>
    <groupId>org.apache.servicemix.tutorial</groupId>
    <version>1.0-SNAPSHOT</version>
  </parent>
  <groupId>org.apache.servicemix.tutorial</groupId>
  <artifactId>tutorial-sa</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jbi-service-assembly</packaging>
  <name>Tutorial :: SA</name>
  <url>http://www.myorganization.org</url>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.servicemix.tooling</groupId>
        <artifactId>jbi-maven-plugin</artifactId>
        <version>${servicemix-version}</version>
        <extensions>true</extensions>
        <configuration>
          <type>service-assembly</type>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <repositories>
    <repository>
      <releases />
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>apache</id>
      <name>Apache Repository</name>
      <url>http://people.apache.org/repo/m2-ibiblio-rsync-repository</url>
    </repository>
    <repository>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots />
      <id>apache.snapshots</id>
      <name>Apache Snapshots Repository</name>
      <url>http://people.apache.org/repo/m2-snapshot-repository</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <releases />
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>apache</id>
      <name>Apache Repository</name>
      <url>http://people.apache.org/repo/m2-ibiblio-rsync-repository</url>
    </pluginRepository>
    <pluginRepository>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots />
      <id>apache.snapshots</id>
      <name>Apache Snapshots Repository</name>
      <url>http://people.apache.org/repo/m2-snapshot-repository</url>
    </pluginRepository>
  </pluginRepositories>
  <dependencies>
    <dependency>
      <groupId>org.apache.servicemix.tutorial</groupId>
      <artifactId>tutorial-file-su</artifactId>
      <version>1.0-SNAPSHOT</version>
    </dependency>

    <dependency>
      <groupId>org.apache.servicemix.tutorial</groupId>
      <artifactId>tutorial-eip-su</artifactId>
      <version>1.0-SNAPSHOT</version>
    </dependency>

    <dependency>
      <groupId>org.apache.servicemix.tutorial</groupId>
      <artifactId>tutorial-jms-su</artifactId>
      <version>1.0-SNAPSHOT</version>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <properties>
    <servicemix-version>3.2.3</servicemix-version>
  </properties>
</project>


此时,一个完整的工程创建完成。
在工程目录(servicemix)下运行命令:
mvn install


当编译运行成功后,在目录下 servicemix/tutorial-sa/target 会生成此工程的jar包:tutorial-sa-1.0-SNAPSHOT.jar。

部署:
只要将tutorial-sa-1.0-SNAPSHOT.jar拷贝到 %SERVICEMIX/hotdeploy目录下即可。
分享到:
评论

相关推荐

    apache-servicemix-4.4-fuseesb第五部分

    3. **Apache ActiveMQ**:作为 Java 消息服务(JMS)提供商,ActiveMQ 在 ServiceMix 中负责处理消息传递。它确保了高可用性和可伸缩性,支持多种消息模式。 4. **JBI(Java Business Integration)**:ServiceMix ...

    apacheservicemix4.4fuseesb-part2

    而“apache-servicemix-4.4.0-fuse-00-43”看起来像是安装包或解压后的文件夹名称,可能包含ESB实例、配置文件、文档和其他资源。 综上所述,这个教程系列的第二部分可能会深入讲解Apache ServiceMix 4.4 和Fuse ...

    apache-servicemix-4.4-fuseesb

    在标题"apache-servicemix-4.4-fuseesb"中,我们可以推断这可能是指Apache ServiceMix的4.4版本,与Red Hat的Fuse ESB产品有关。Fuse ESB是ServiceMix的一个分支,专注于提供轻量级、高性能的集成解决方案。 在描述...

    apache-servicemix-3.3-src.zip

    这个压缩包“apache-servicemix-3.3-src.zip”包含了ServiceMix 3.3版本的源代码,这对于开发者来说是一个宝贵的资源,因为它允许他们深入理解项目的内部工作原理,进行定制化开发,或者对软件进行调试和优化。...

    apache-servicemix-4.4-fuseesb第三部分

    - "apache-servicemix-4.4.0":这是 Apache ServiceMix 的一个特定版本,4.4.0 表示该版本是 ServiceMix 4 系列中的第四个主要稳定版本。 - "fuse":这部分表明这个版本与 Fuse ESB 相关,可能是 ServiceMix 带有 ...

    apache-servicemix-4.4-fuseesb第四部分

    总之,"apache-servicemix-4.4-fuseesb第四部分"的资料涵盖了 Apache ServiceMix 4.4.0 和 Fuse ESB 的核心特性、使用场景和开发实践,是深入了解和掌握这两个 ESB 平台的重要资源。通过深入学习和实践,用户能够...

    ServiceMix-manual-cn

    ServiceMix-manual-cn

    org.apache.servicemix.bundles.spring-jdbc-3.2.8.RELEASE_2.zip

    标题 "org.apache.servicemix.bundles.spring-jdbc-3.2.8.RELEASE_2.zip" 提供的信息表明,这个压缩包包含了 Apache ServiceMix 的一个捆绑包,具体是 Spring JDBC 模块的 3.2.8.RELEASE 版本的第二次更新。Apache ...

    apache-servicemix-4.4.0(1)

    在提供的文件“apache-servicemix-4.4.0-fuse-00-43”中,可能包含了Apache ServiceMix 4.4.0的完整安装包或特定版本的更新。这个版本可能具有特定的修复、增强或特定的集成,比如与Fuse相关的特性,以便在特定环境...

    servicemix-core-3.4.1.zip

    【标题】"servicemix-core-3.4.1.zip" 提供的是Apache ServiceMix核心组件的3.4.1版本。Apache ServiceMix是一个开放源码的企业服务总线(ESB),它基于Java企业版(Java EE)规范,如JBI(Java Business ...

    servicemix-script-2011.01.zip

    【标题】"servicemix-script-2011.01.zip" 是一个与Apache ServiceMix相关的脚本集合,发布于2011年1月。Apache ServiceMix是基于Java的、开源的企业服务总线(ESB),它提供了一个灵活的平台来集成不同系统和服务。...

    org.apache.servicemix.bundles.spring-jdbc-4.0.2.RELEASE_1.zip

    【标题】"Apache ServiceMix Bundles - Spring JDBC 4.0.2.RELEASE_1" Apache ServiceMix 是一个全面的企业级服务导向架构(SOA)平台,它基于Java语言和OSGi规范。这个压缩包“org.apache.servicemix.bundles....

    servicemix-core-3.3.2-javadoc

    ServiceMix是Apache软件基金会下的一个开源企业服务总线(ESB)项目,它基于Java语言,提供了强大的集成和消息传递能力。本文主要针对ServiceMix Core 3.3.2版本的Javadoc文档进行深入解析,帮助开发者更好地理解和...

    ESB比较 adfasdfasf

    - Apache ServiceMix: 3分 - IBM Websphere ESB: 3分 3. **ESB产品的完整性**: - BEA AquaLogic: 5分 - Mule: 5分 - Apache ServiceMix: 2分 - IBM Websphere ESB: 5分 4. **ESB安全特性与功能**: - BEA ...

    Apache ServiceMix Specs :: JAXP API 1.3

    Apache ServiceMix Specs :: JAXP API 1.3

    org.apache.servicemix.bundles.spring-aspects-3.2.8.RELEASE_2.zip

    标题中的"org.apache.servicemix.bundles.spring-aspects-3.2.8.RELEASE_2.zip"指示了这是一个与Apache ServiceMix相关的软件包,特别地,它包含了Spring框架的一个特定版本——3.2.8.RELEASE的面向切面编程(AOP)...

    org.apache.servicemix.bundles.spring-test-3.2.8.RELEASE_2.zip

    标题中的"org.apache.servicemix.bundles.spring-test-3.2.8.RELEASE_2.zip"表明这是一个关于Apache ServiceMix的Spring测试框架的版本包。Apache ServiceMix是基于Java的全面企业级服务总线(ESB),它集成了许多...

    org.apache.servicemix.bundles.elasticsearch-1.0.1_1.zip

    标题中的"org.apache.servicemix.bundles.elasticsearch-1.0.1_1.zip"表明这是一个与Apache ServiceMix相关的软件包,特别地,它包含了Elasticsearch的一个特定版本(1.0.1)的bundle。Apache ServiceMix是基于Java...

Global site tag (gtag.js) - Google Analytics