FWD: Creating an Executable Apache Pivot App using Maven

old archive url :http://michaelbushe.wordpress.com/2009/12/22/creating-an-executable-apache-pivot-app-using-maven/

Apache Pivot is a very interesting new RIA platform.  You can think of it as a competitor to flex, Silverlight, and JavaFX.  Unlike all three of those languages, it uses Java and XML – two generally familiar languages, to create applications.  It’s structured similar to flex – it has an XML file that describes an application’s layout and allows enough functionality to create simple and not so simple applications with just XML with embedded scripts.  Unlike flex, the “code behind” language is straight up Java.  It’s deployment model is just like an applet’s, so it’s ubiquitous.  When you dig deeper, there are lots of little niceties – things that are simple and make sense.  It’s nice to work with.

This post describes how to set up a maven project to build and deploy an Apache Pivot application.  Once Pivot is in the maven central repo (it’s not quite out of incubator as of this writing), then the result of this post can be made into an archetype and contributed back.  The result of this post is is this GitHub repository commit.  (Git is very nifty – the fact that the entire set of files is available from one Git commit id is, well, wicked, as we say in Massachusetts.)

We’ll steal the code from the Pivot StockTracker tutorial, since it will be extended with a graph and used as an example of how and why to use the EventBus in UIs.  The examples will be posted on the EventBus.org blog soon.   I’ll add a blog entry here when the eventbus.org blog post is available.

Start by using the maven quickstart to create a blank Java project from an archetype:

mvn archetype:create -DgroupId=org.eventbus.tutorial -DartifactId=stocktracker
cd stocktracker
mvn install

To populate the example, we can pull the StockTracker sources to the our package in the src/main/java directory and delete the files we don’t need:

mkdir src/main/java/org/eventbus/tutorials/pivot/stocktracker
cd src/main/java/org/eventbus/tutorials/pivot/stocktracker
svn co http://svn.apache.org/repos/asf/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/stocktracker/ .
rm -rf .svn
rm App.java
rm ../../../../../../../test/java/org/eventbus/tutorial/AppTest.java

According to Maven conventions, only the java code belongs in this directory, so let’s move the other files to the resource directory so that they can easily be picked up from the jar at runtime.  A better practice may be to make image, json, and wtkx directory, or maybe make a main/wtkx directory for the latter, but let’s keep it simple.  The community may come up with better standards for Pivot development with Maven.

cd ../../../../../..
mkdir resources
mv java/org/eventbus/tutorial/*.json resources/org/eventbus/tutorials/pivot/stocktracker
mv java/org/eventbus/tutorial/*.png resources/org/eventbus/tutorials/pivot/stocktracker
mv java/org/eventbus/tutorial/*.wtkx resources/org/eventbus/tutorials/pivot/stocktracker

Change all the packages in the Java files to the new package.

find . -name *.java -print | xargs sed -i -e 's/org.apache.pivot.tutorials.stocktracker/org.eventbus.tutorials.pivot.stocktracker/g'
find . -name *.wtkx -print | xargs sed -i -e 's/org.apache.pivot.tutorials.stocktracker/org.eventbus.tutorials.pivot.stocktracker/g'

(This is why I keep such detailed blogs.  It took me while to figure out that the -e is required on Mac, but not Linux, and I’m sure I’ll forget again, but I’ll remember that I had to do this before.)

The maven default build uses Java 1.3 source, even though Java 1.5 is about to be obsoleted as of this writing, so we’ll have to tell maven to get with the new decade and use  Java 6  (I think Pivot will work for Java 5 too) by adding this before <dependencies>:

<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test/src</testSourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>

Pivot is not in the central maven repo yet, so we have to install it locally, which means building it first.  The Pivot team is rock solid, pulling and building the project is easy and reliable.  See the BUILD file in the svn trunk for details, but on a Mac using Java 6, it’s like this:

cd ~
mkdir pivot
svn co http://svn.apache.org/repos/asf/incubator/pivot/trunk/ .
export CLASSPATH=~/dev/maven-ant-tasks-2.1.0.jar:~/dev/junit/junit-4.8.1.jar:/System/Library/Frameworks/JavaVM.framework/Resources/Deploy.bundle/Contents/Home/lib/plugin.jar:/System/Library/Frameworks/JavaVM.framework/Resources/Deploy.bundle/Contents/Home/lib/javaws.jar
ant maven-install

This builds all the pivot jars using ant and installs them to your local maven repo.

Now go back to our project and add the pivot dependencies to pom.xml:

<dependencies>
<dependency>
<groupId>org.apache.pivot</groupId>
<artifactId>pivot-core</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.pivot</groupId>
<artifactId>pivot-wtk</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.pivot</groupId>
<artifactId>pivot-web</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.pivot</groupId>
<artifactId>pivot-wtk-terra</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.pivot</groupId>
<artifactId>pivot-charts</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>

You might not need charts, but I will for the EventBus stuff coming soon.

Now

mvn install

should lead to a successful build.

It would be real nice to generate an executable jar file that has the entire classpath in it so that launching the app is a simple java -jar command.  To do this add the following as a plugin after the compiler plugin configuration shown above:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>attached</goal>
</goals>
<phase>package</phase>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>org.eventbus.tutorials.pivot.stocktracker.StockTracker</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>

Now run build again and launch the app:


mvn clean install
java -jar target/stocktracker-1.0-SNAPSHOT-jar-with-dependencies.jar

maven 发布项目到nexus服务器中

首先对Nexus服务器的Repositories中的类型有个了解,主要分为group、Hosted、Proxy和Virtual四种类型。
我们只能用Hosted作为发布的目标仓库。
1、配置.m2/settings.xml

<servers>
  <server>
    <id>nexus-releases</id>
     <username>admin</username>
     <password>****</password>
  </server>
   <server>
     <id>nexus-snapshots</id>
     <username>admin</username>
     <password>****</password>
   </server>
 </servers>

2.配置项目POM.xml



nexus-releases
public
http://localhost:8080/nexus/content/repositories/releases


nexus-snapshots
Snapshots
http://localhost:8080/nexus/content/repositories/snapshots


3.发布项目
进入项目目录执行mvn deploy结束后,构件就自动加入到服务器中,其他项目就可以进行关联引用。

参考:
Maven2部署构件到Nexus时出现的Failed to transfer file错误
Maven2中需要注意的问题
maven deploy到nexus私服出错问题

Maven发布jar到本地与远程库中

由于电信短信平台二次开发中使用了maven进行项目管理,在添加依赖jar包时,需要将sendMsg_jdk1.6.jar安装到maven中,让maven自动进行加载。
使用maven2的安装命令。
命令格式如下:
1、本地发布
[color=Green]mvn install: install-file -Dfile=sendMsg_jdk1.6.jar -DgroupId=com.linkage
-DartifactId=netmsg -Dversion=2.0(jdk1.6) -Dpackaging=jar[/color]
2、远程发布
[color=Green]mvn deploy:deploy-file -DgroupId=com.link
age -DartifactId=netmsg -Dversion=2.0(jdk1.6) -Dpackaging=jar -Dfile=sendMsg_jdk
1.6.jar -Durl=http://localhost:8080/nexus/content/repositories/releases
-DrepositoryId=nexus-releases[/color]

在项目POM.xml中加入:


com.linkage
netmsg

2.0(jdk1.6)

注:关于repositoryId=nexus-releases说明,nexus-releases在.m2/settings.xml中已经配置。
参考:16.7.3. 部署第三方构件

收藏 M2Eclipse:Maven Eclipse插件无法搜索远程库的解决方法

使用Eclipse安装了maven插件之后,创建Maven工程,发现添加依赖“Add Dependency”的时候无法自动搜索远程库。

如果不能搜索远程库那用这个插件有啥用撒。。。

查遍了所有的maven配置文件都没发现问题。

最后发现是插件本身的问题。原因是远程库的索引没有成功的建立。

很有可能安装插件之后的某一次“Update Indexes”失败之后,导致默认的index“http://repo1.maven.org/maven2/”无法继续更新。所以每次都会报错: Unable to update index for central http ://repo1 .maven .org /maven2 / 。

也就说一次更新失败导致了以后的Update index都失败了。

这个时候执行以下操作:

http://readthefuckingmanual.net/error/2394/

Do in eclipse: window->show view->other->maven->maven indexes. One of the indexes is:

http://repo1.maven.org/maven2.

right-click on this one, and try rebuild index.
If that does not work, create a new index with the same address, and do a rebuild of that. With me that worked, and I could remove the original one. After this a restart of eclipse will NOT show the error anymore, and the add dependency search function operates as it should. Problem solved.

另外,参考 http://forum.springside.org.cn/redirect.php?tid=2876&goto=lastpost,可以获得加快索引建立的方法。

解决Spring Tool Suite和Maven2找不到JDK的问题

在运行Spring Tools Suite工具,创建Maven Project时,报eclipse找不到JDK环境,请配置Eclipse JDK环境。
打开E:\springsource\sts-2.3.0.RELEASE目录中的STS.ini文件,加入-vm参数,具体如下:
[color=Red][size=15]-vm
C:\Program Files\Java\jdk1.6.0_13\bin\javaw.exe[/size][/color]
-startup
plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
–launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v20090519
-product
com.springsource.sts.ide
–launcher.XXMaxPermSize
256M
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx1G
-XX:MaxPermSize=256m

注:vm后面一定要加换行,也不知道是什么原因,不换行还是报错。

Maven2 常用命令

mvn archetype:create :创建 Maven 项目

mvn compile :编译源代码

mvn test-compile :编译测试代码

mvn test : 运行应用程序中的单元测试

mvn site : 生成项目相关信息的网站

mvn clean :清除目标目录中的生成结果

mvn package : 依据项目生成 jar 文件

mvn install :在本地 Repository 中安装 jar

mvn eclipse:eclipse :生成 Eclipse 项目文件

生成项目

建一个 JAVA 项目 : mvn archetype:create -DgroupId=com.demo -DartifactId=App

建一个 web 项目 : mvn archetype:create -DgroupId=com.demo -DartifactId=web-app -DarchetypeArtifactId=maven-archetype-webapp

生成 Eclipse 项目

普通 Eclipse 项目执行 : mvn eclipse:eclipse

Eclipse WTP 项目执行 : mvn eclipse:eclipse –Dwtpversion=1.0

( wtp1.0 以上版本均可用)

pom.xml 文件基本节点介绍

:文件的根节点 .
: pom.xml 使用的对象模型版本 .
:创建项目的组织或团体的唯一 Id.
:项目的唯一 Id, 可视为项目名 .

:打包物的扩展名,一般有 JAR,WAR,EAR 等
:产品的版本号 .
:项目的显示名,常用于 Maven 生成的文档。
:组织的站点,常用于 Maven 生成的文档。
:项目的描述,常用于 Maven 生成的文档。

在 POM 4 中, 中还引入了 ,它主要管理依赖的部署。

目前 可以使用 5 个值:

compile :缺省值,适用于所有阶段,会随着项目一起发布。

provided :类似 compile ,期望 JDK 、容器或使用者会提供这个依赖。如 servlet.jar 。

runtime :只在运行时使用,如 JDBC 驱动,适用运行和测试阶段。

test :只在测试时使用,用于编译和运行测试代码。不会随项目发布。

system :类似 provided ,需要显式提供包含依赖的 jar , Maven 不会在 Repository 中查找它。

定义自己的结构

新建一个 archetype 项目 :

mvn archetype:create\
-DgroupId=cn.prof\
-DartifactId=prof-archetype\
-DarchetypeArtifactId=maven-archetype-archetype

主要的模板文件 : archetype-resources/pom.xml

修改其中内容

修改 META-INF/maven/archetype.xml 中定义了相关的 sources

安装此项目 : mvn install

执行下面的命令创建新目录的项目:

mvn archetype:create -DgroupId=com.mergere.mvnbook \
-DartifactId=proficio-example\
-DarchetypeGroupId=com.xxx.mvn\
-DarchetypeArtifactId= prof-archetype \
-DarchetypeVersion=1.0-SNAPSHOT

Maven 2 JasperReports Plugin配置

在使用MAVEN来配置项目时,要用到JasperReports,可以在POM中加入链接。

POM dependencies片段:
  1. <dependency>  
  2.   <groupId>jasperreports</groupId>  
  3.   <artifactId>jasperreports</artifactId>  
  4.   <version>3.1.2</version>  
  5. </dependency>  

但是想在项目编译时,要将指定目录的*.jrxml进行编译的话需要加入Build插件。

POM build plugins片段:
  1. <plugin>  
  2.                 <groupId>org.codehaus.mojo</groupId>  
  3.                 <artifactId>jasperreports-maven-plugin</artifactId>  
  4.                 <executions>  
  5.                     <execution>  
  6.                         <goals>  
  7.                             <goal>compile-reports</goal>  
  8.                         </goals>  
  9.                     </execution>  
  10.                 </executions>  
  11.   
  12.                 <dependencies>  
  13.                     <!– 
  14.                         note this must be repeated here to pick up correct xml validation 
  15.                     –>  
  16.                     <dependency>  
  17.                         <groupId>jasperreports</groupId>  
  18.                         <artifactId>jasperreports</artifactId>  
  19.                         <version>3.1.2</version>  
  20.                     </dependency>  
  21.                 </dependencies>  
  22.   
  23.             </plugin>  

使用:mvn jasperreports:compile-reports -Ddetail=true

附上JasperReport Plugins的命令参数说明。

Optional Parameters

Name Type Since Description
additionalClasspath String - Any additional classpath entry you might want to add to the JasperReports compiler. Not recommended for general use, plugin dependencies should be used instead.
additionalProperties Map 1.0-beta-2 Additional JRProperties
classpathElements List - (no description)
compiler String - Uses the Javac compiler by default. This is different from the original JasperReports ant task, which uses the JDT compiler by default.
Default value is: net.sf.jasperreports.engine.design.JRJavacCompiler.
javaDirectory File - This is where the generated java sources are stored.
keepJava boolean - Deprecated. There seems to be an issue with the compiler plugin so don’t expect this to work yet – the dependencies will have disappeared.
Default value is: false.
keepSerializedObject boolean - Deprecated. Not implemented
Default value is: true.
outputDirectory File - This is where the .jasper files are written.
outputFileExt String - The extension of the compiled report files. Creates files with a .jasper extension by default.
Default value is: .jasper.
project MavenProject - (no description)
sourceDirectory File - This is where the xml report design files should be.
Default value is: src/main/jasperreports.
sourceFileExt String - The extension of the source files to look for. Finds files with a .jrxml extension by default.
Default value is: .jrxml.
xmlValidation boolean - Wether the xml design files must be validated.
Default value is: true.

Flexmojos Using ASDoc

flexmojos插件中,如何为Maven flexmojos构建的flex项目自动生成帮助文档?

可以有如下两种办法:

1.通过命令来生成,在构建的项目根目录中执行如下命令:
$ mvn org.sonatype.flexmojos:flexmojos-maven-plugin:asdoc

会在target/asdoc目录中生成HTML文件。

2.在项目pom.xml文件中进行配置,加入如下配置:
XML/HTML代码


<build>
<plugins>
<plugin>
<groupid>org.sonatype.flexmojos</groupid>
<artifactid>flexmojos-maven-plugin</artifactid>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>asdoc</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

当执行$mvn compile等命令时就会自动产生文档。

http://www.bonashen.com/attachments/month_0912/q20091226212711.JPG

收藏Flexmojos Adding libraries to compilation

When developing with flex, it is very common to need 3rd party libraries to build more elaborate applications. For example: if an application uses charts, the project will require datavisualization.swc.  If an application needs an SHA1 algorithm, it will require as3corelib, and so on.

Using adobe’s command line compilers (mxmlc and compc) you will use parameters from this list:
-compiler.external-library-path
-compiler.include-libraries
-compiler.library-path
-runtime-shared-library-path

But on flex-mojos those options are not available. If there is no option available, how does one add these libraries?

Simple, following maven way =D

Each required library must be added as a dependency. If you need datavisualization you will add a dependency like this:

<dependency>
  <groupId>com.adobe.flex.sdk</groupId>
  <artifactId>datavisualization</artifactId>
  <version>3.0.0.477</version>
  <type>swc</type>
</dependency>

One big question: How do you discover the dependency’s groupId and artifactId?
As with any module in maven, those who created the module must define their groupId and artifactId. Since flex is not very popular with the maven world, it most likely will not be available in any maven repository. If this is the case, you will define your own groupId/artifactId and install on your own repository.

Maven Guide to installing 3rd party JARs

Often times you will have 3rd party JARs that you need to put in your local repository for use in your builds. The JARs must be placed in the local repository in the correct place in order for it to be correctly picked up by Maven. To make this easier, and then error prone, we have provide a goal in the install plug-in which should make this relatively painless. To install a JAR in the local repository use the following command:
mvn install:install-file -Dfile= -DgroupId= -DartifactId= -Dversion= -Dpackaging=

You can follow the same logic for swc libraries.

Example for installing the Data Visualization swc’s into Maven.

Download data visualization swc’s from here, you need to install them into your maven repo as follows:

  • extract the zip file and cd to the datavisualization_sdk3.3/frameworks/libs and issue the mvn install command.
    mvn install:install-file -DgroupId=com.adobe.flex.framework -DartifactId=datavisualization -Dversion=3.3.0.4852 -Dpackaging=swc -Dfile=datavisualization.swc
    

  • do the same for /frameworks/locale/en_US and run the following commands:
    mvn install:install-file -DgroupId=com.adobe.flex.framework -DartifactId=datavisualization -Dversion=3.3.0.4852 -Dclassifier=en_US -Dpackaging=rb.swc -Dfile=datavisualization_rb.swc
    

You will need the matching dependencies in your pom:

<dependency>
   <groupId>com.adobe.flex.framework</groupId>
   <artifactId>datavisualization</artifactId>
   <version>3.3.0.4852</version>
   <type>swc</type>
 </dependency>
 <dependency>
   <groupId>com.adobe.flex.framework</groupId>
   <artifactId>datavisualization</artifactId>
   <classifier>en_US</classifier>
   <version>3.3.0.4852</version>
   <type>rb.swc</type>
 </dependency>

 

How do you define how the dependency should be used? If it should be external, how do you get it?
Defining dependency scope:

<dependency>
  <groupId>com.adobe.flex.sdk</groupId>
  <artifactId>datavisualization</artifactId>
  <version>3.0.0.477</version>
  <type>swc</type>
  <scope>external</scope>
</dependency>

Flex-mojos supports 6 scopes:

  • merged: this is the default value, when not defined will assume merged. That means SWC/SWF file will be bigger and self sufficient. Same as -compiler.library-path
  • internal: all dependency content will be included on target SWC/SWF. Biggest compiled file. Same as -compiler.include-libraries
  • external: no dependency content will be included on target SWC/SWF. Smaller compiled file. Makes no sense to use this scope on SWF compilation. Same as -compiler.external-library-path
  • rsl: no dependency content will be inclued on SWC/SWF. But, SWF will have a reference to load it a runtime. Do not use on SWC compilation. Same as -runtime-shared-library-path
  • caching: same as RSL, but uses adobe signed SWZ files.
  • test: libraries required to run tests. Same as -compiler.include-libraries, but at test template only!

flexmojos 创建flex项目常用构建命令

flexmojos has its own archetypes for flex application, so here they are:

Create library: $ mvn archetype:generate -DarchetypeRepository=http://repository.sonatype.org/content/groups/flexgroup -DarchetypeGroupId=org.sonatype.flexmojos -DarchetypeArtifactId=flexmojos-archetypes-library -DarchetypeVersion=[flexmojos targeted version]

Create application: $ mvn archetype:generate -DarchetypeRepository=http://repository.sonatype.com/content/groups/flexgroup -DarchetypeGroupId=org.sonatype.flexmojos -DarchetypeArtifactId=flexmojos-archetypes-application -DarchetypeVersion=[flexmojos targeted version]

Create modular application: $ mvn archetype:generate -DarchetypeRepository=http://repository.sonatype.org/content/groups/flexgroup -DarchetypeGroupId=org.sonatype.flexmojos -DarchetypeArtifactId=flexmojos-archetypes-modular-webapp -DarchetypeVersion=[flexmojos targeted version]

 

正常构建后的项目pom.xml文件结构如下:
XML/HTML代码
  1. <project xmlns="http://maven.apache.org/POM/4.0.0"  
  2. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0  
  4. http://maven.apache.org/maven-v4_0_0.xsd">  
  5.   
  6.   <modelVersion>4.0.0</modelVersion>  
  7.   <groupId>ua.com.xoas</groupId>  
  8.   <artifactId>testapp</artifactId>  
  9.   <version>1.0</version>  
  10.   <packaging>swf</packaging>  
  11.   
  12.   <name>testapp Flex</name>  
  13.   
  14.   <build>  
  15.    <sourceDirectory>src/main/flex</sourceDirectory>  
  16.    <testSourceDirectory>src/test/flex</testSourceDirectory>  
  17.    <plugins>  
  18.     <plugin>  
  19.      <groupId>org.sonatype.flexmojos</groupId>  
  20.      <artifactId>flexmojos-maven-plugin</artifactId>  
  21.      <version>3.2.0</version>  
  22.      <extensions>true</extensions>  
  23.     </plugin>  
  24.    </plugins>  
  25.   </build>  
  26.   
  27.   <dependencies>  
  28.    <dependency>  
  29.     <groupId>com.adobe.flex.framework</groupId>  
  30.     <artifactId>flex-framework</artifactId>  
  31.     <version>3.2.0.3958</version>  
  32.     <type>pom</type>  
  33.    </dependency>  
  34.   
  35.    <dependency>  
  36.     <groupId>org.sonatype.flexmojos</groupId>  
  37.     <artifactId>flexmojos-unittest-support</artifactId>  
  38.     <version>3.2.0</version>  
  39.     <type>swc</type>  
  40.     <scope>test</scope>  
  41.    </dependency>  
  42.   </dependencies>  
  43.   
  44. </project>  

如果你要增加flexmojos的扩展参数需要如下配置:

 

XML/HTML代码
  1. <build>  
  2.  <sourceDirectory>src/main/flex</sourceDirectory>  
  3.  <testSourceDirectory>src/test/flex</testSourceDirectory>  
  4.  <plugins>  
  5.   <plugin>  
  6.     <groupId>org.sonatype.flexmojos</groupId>  
  7.     <artifactId>flexmojos-maven-plugin</artifactId>  
  8.     <version>3.2.0</version>  
  9.     <extensions>true</extensions>  
  10.     <configuration>  
  11.       <!–在这儿加入你的配置参数 –>  
  12.       <!–详细参数说明见
    http://sites.sonatype.org/flexmojos/flexmojos-maven-plugin/plugin-info.html 

    >  
  13.       <debug>true</debug>  
  14.       <allowSourcePathOverlap>true</allowSourcePathOverlap>  
  15.     </configuration>  
  16.   </plugin>  
  17.  </plugins>  
  18. </build>  

如果要将flexmojos生成的项目转换成flexbuilder项目请在创建的项目目录下执行如下命令:

$ mvn flexmojos:flexbuilder

Spring ActionScript 0.8 发布

Dear Community,

I’m pleased to announce that the Spring ActionScript 0.8 release is now available.

DownloadAPI DocumentationHTML DocsPDF DocsChangelog

This release includes the Spring ActionScript framework, the Cairngorm extensions and the PureMVC extensions.

All libraries are available for download at the following Maven repository: http://projects.yoolab.org/maven/content/repositories/

From now on, we will regularly publish new snapshots of the libraries there.

Direct links to the libraries:
- Spring ActionScript 0.8
- Spring ActionScript Cairngorm 0.8
- Spring ActionScript PureMVC 0.8

Dependencies:
- AS3Commons Lang
- AS3Commons Logging
- AS3Commons Reflect

Note: AS3Commons Lang is a snapshot of 1.0. We will work with a release for the following releases of Spring ActionScript

Besides a series of bugfixes, optimizations and improvements, some of the major changes and enhancements include:

Autowiring support

Using autowiring allows you to inject objects managed by the container into view components and other objects. To autowire a property, annotate it with the [Autowired] metadata tag. The support we build in is pretty enhanced and allows you to customize the autowire behavior in many different ways. Within the Autowired metadata tag you can specify the object name and you can also configure the container to filter autowire candidates using your own filter specifications. Please see the documentation on autowiring for more info.

Custom Namespaces

The XML configuration now supports namespaces and allows you to create custom namespaces yourself. A few namespaces have been added to simplify the configuration of common objects for RMI and Messaging. More info on available namespaces and schemas and creating custom ones can be found in the documentation. The XSD schemas are available http://www.springactionscript.org/schema/

MXML Configuration

We now also support configuration through MXML. The markup is very similar to the regular XML config, but with some slight differences. Please see the documentation on MXML Configuration

AS3Commons

As a side project, we have started the AS3Commons project that offers reusable ActionScript 3.0 libraries. Most of the libraries currently available in AS3Commons are build using code from the Spring ActionScript framework. This means that a lot of code has been removed from Spring ActionScript and is now available for use in projects not using Spring ActionScript. Please note that you might have to update quite some import statements to refer to AS3Commons instead of Spring ActionScript. We apologize for any inconvenience this might cause, but this is only a one-time process.

We hope you find the AS3Commons libraries useful. All libraries (releases and snapshots) can also be found at the Maven repository.

Documentation

The documentation has been tremendously improved in this version. Next to the API documentation, we now provide a reference guide in HTML and PDF format. General info can be found at the project website: www.springactionscript.org

Last Words

If you feel like helping us out, we could certainly use your help. This project is entirely created on a volunteer basis and in our spare (and limited) free time so needless to say that the more people, the faster we can deliver new releases and guarantee the quality of the framework. So if you think you have someting to offer, be it as a developer, tester, documentation writer, sample creator, … please contact me (christophe [DOT] herreman [AT] gmail [DOT] com) or leave something in the comments. All help is more than welcome.

Enjoy this release and have fun coding!

Spring ActionScript简介

Note: The Spring ActionScript framework was formerly known as the Prana framework and has now been moved under the Spring umbrella as a Spring Extensions project.

Spring ActionScript is an Inversion of Control (IoC) Container for ActionScript 3.0, and more specifically the flex framework. It enables you to configure objects and components in a non-intrusive way by describing them in an external xml document and having them loaded at runtime.

At its core is a Spring-ish application context and IoC container. The xml dialect for the application context is aimed to be Spring compliant.

Further, the framework also contains utility classes for configuring and extending Cairngorm and PureMVC applications, an MVCS base architecture and general utilities. In the future we’ll be looking into adding AOP support, and we’re always open for suggestions.

Current Release

The current release is Spring ActionScript 0.7. (see the announcement)

Links

Download: https://sourceforge.net/project/showfiles.php?group_id=194107&package_id=306949
Changelog: http://www.pranaframework.org/docs/0.7/changelog.txt
API Docs: http://www.pranaframework.org/docs/0.7/api
Forum: http://forum.springframework.org/forumdisplay.php?f=60
Maven site: http://www.pranaframework.org/springactionscript
SVN: https://src.springframework.org/svn/se-springactionscript-as
FishEye: https://fisheye.springframework.org/browse/se-springactionscript-as
JIRA: http://jira.springframework.org/browse/SESPRINGACTIONSCRIPTAS

Eclipse .classpath 简要说明

<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
    每个新建java工程(Project)都默认存在的。

<classpathentry kind="src" ōutput="km230/apitest/classes" path="km230/apitest/src"/>
    指定源文件位置, 对应工程属性Java build path中Source项中的一项, kind="src" 指明为源文件, 源文件路径path, output为这条路径中源文件编译以后class文件的输出路径。

<classpathentry kind="src" path="km230batch/src"/>
    指定源文件位置, 对应工程属性Java build path中Source项中的一项, kind="src" 指明为源文件, 源文件路径path, 编译以后class文件的输出路径为默认输出路径。

<classpathentry kind="output" path="km230server/approot/WEB-INF/classes"/>
    指定编译以后class文件的默认输出路径, 对应工程属性Java build path中Source项中的default output path, kind="output"指明为默认class输出路径, path为相应输出路径。
   
    注意: 这一条在文件中有且只能有一条(不可能同时出现两个默认吧?).

<classpathentry kind="lib" path="km230/lib/Notes.jar"/>
    指定工程所用到的库文件或目录, 对应工程属性Java build path中Libraries项中的一项, kind="lib"指明为库文件或目录, path为库文件或目录位置。
   
    注意: 当指定库文件时(非库目录, 通常是jar包, 好像zip也可以, 不知道是否还有其它), 应当包含文件名。

<classpathentry kind="var" path="JUNIT_HOME/junit.jar" sourcepath="ECLIPSE_HOME/plugins/org.eclipse.jdt.source_3.0.0/src/org.junit_3.8.1/junitsrc.zip"/>
   指定工程所用到的库文件或目录, 对应工程属性Java build path中Libraries项中的一项, kind="var"指明带有全局编译路径中设置的变量(Window->Prefrences->Java->Build Path->Classpath Variables), 如上面的ECLIPSE_HOME, path为这个变量目录下的库文件(同样通常是jar包, 好像zip也可以, 也不知道是否还有其它)。

<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>

在myeclipse 中如果使用MAVEN插件时,会发现如上配置,由maven管理的关联lib将会自动添加到系统的libraries项中。