Mais conteúdo relacionado Semelhante a 企业级软件的组件化和动态化开发实践 (20) 企业级软件的组件化和动态化开发实践2. ‣
‣
‣ WTP Facet XDoclet ANT
‣ OSGi——
‣ Java Bundle
9. ‣ ‣
‣ ‣
‣ ‣
‣ ‣
‣ ‣
‣ ‣
‣ ‣
10. Metadata
Workflow
‣ ‣ RuleEngine
‣ ‣
‣ ‣
‣ ‣
‣ ‣
‣ ‣
‣ ‣
Component Building
12. ...
ERP
Flex
AJAX
Main FrameWork
13. ...
ERP
Flex
AJAX
Main FrameWork
14. ...
ERP
Here you are!
Flex
AJAX
Main FrameWork
15. ...
Flex AJAX
ERP
GAP-API
Main FrameWork
16. ‣ Eclipse WTP Facets
‣ XDoclet
‣ Ant
‣ OSGi
‣
‣ Servlet
‣
18. WTP Faceted
id versions requires conflicts
jst.java 1.3, 1.4, 1.5, 1.6 jst.ear
jst.web 2.2, 2.3, 2.4 jst.java jst.ear, jst.ejb
jst.ear 1.2, 1.3, 1.4, 5.0, 6.0 jst.java
jst.ejb 1.1, 2.0, 2.1, 3.0, 3.1 jst.java jst.ear, jst.java
19. WTP Faceted
id versions requires conflicts
jst.java 1.3, 1.4, 1.5, 1.6 jst.ear
jst.web 2.2, 2.3, 2.4 jst.java jst.ear, jst.ejb
jst.ear 1.2, 1.3, 1.4, 5.0, 6.0 jst.java
jst.ejb 1.1, 2.0, 2.1, 3.0, 3.1 jst.java jst.ear, jst.java
23. ‣ build.xml
‣ -MergePoint i18n oid spring include
‣ TotalBuild
‣ Facet
28. ‣
‣ build.xml clean compile jar distribution
db
merge
resource
‣ ant src
webModule
‣ Distribution
29. Merge
‣ xdt
‣ applicationContext.xdt------------spring
‣ global.xdt---------------------------include global.jsp
‣ web.xdt-----------------------------web.xml
‣ ......
‣ Merge Point
<XDtMerge:merge file="workflow-hbm.data"></XDtMerge:merge>
31. XDoclet <path id="xdoclet.classpath">
<fileset dir="${lib.dir}">
<include name="*.jar"/>
‣ XDoclet classpath </fileset>
<pathelement location="classes"/>
</path>
‣ Ant taskdef
‣ target <taskdef name="xdoclet" classname="xdoclet.DocletTask"
classpathref="xdoclet.classpath" />
<target name="gen-applicationContext.xml">
<xdoclet destdir="${webmodule.dir}/WEB-INF/conf/applicationContext" force='true' mergedir="${merge.dir}">
<fileset dir="${source.dir}" includes="**/*.java" />
<template templateFile="template/applicationContext.xdt" destinationfile="applicationContext.xml" />
</xdoclet>
</target>
32. TotalBuild
‣ Facets
<!-- build.xml-->
<target name="build">
<ant dir="${gap-api}" antfile="build.xml" target="all" />
<ant dir="${venus-frame}" antfile="build.xml" target="all" />
<ant dir="${venus-page}" antfile="build.xml" target="all" />
<ant dir="${venus-log}" antfile="build.xml" target="all" />
......
</target>
<!-- -->
<target name="plugin">
<available file="Templates" type="dir" property="Templates.present" />
<antcall target="clean" />
<move todir="Templates/0. ">
<fileset dir="${gap-api}/dist" />
<fileset dir="${venus-frame}/dist" />
</move>
......
</target>
33. Facet
‣ org.eclipse.ui.newWizards
‣ category wizard
34. ‣ org.eclipse.wst.common.project.facet.core.facets
‣ <category />——Facet
‣ <project-facet />——Facet
‣ <project-facet-version />——Facet
‣ <template />—— Facet
‣ <preset />—— Facet
——
‣ org.eclipse.wst.common.project.facet.ui.images
‣ org.eclipse.wst.common.project.facet.ui.wizard
35. Facet
<!--Facet -->
<project-facet id="gap.mainframe">
<label>0. </label>
<description>GAP </description>
<category>gap.category</category>
</project-facet>
<!-- Facet -->
<project-facet-version facet="gap.mainframe" version="3.7">
<action id="gap.mainframe.install" type="INSTALL">
<delegate class="venus.tools.ide.facet.GAPFacetInstallDelegate"/>
</action>
<constraint>
<requires facet="jst.web" version="[2.4"/>
</constraint>
</project-facet-version>
36. Facet
‣ org.eclipse.wst.common.project.facet.core.IDelegate
‣ GAPFacetInstallDelegate Facet
‣ BuildFacetsDelegate
‣ Facet Facet
‣ Facet
‣ XDoclet classpath
‣ project nature .tomcatplugin
‣
38. ‣
‣ jar
‣ Install Update Remove
‣ Time For:
39. ‣
‣ jar
‣ Time For:Update
Install Remove
‣ Time For:
O Gi
40. OSGi
‣
‣ 2005 R4.0 ——
‣ 2010 3 OSGi 4.2
‣ Bundle
41. update
install refresh
INSTALLED STARTING
resolve update
start
refresh
RESOLVED ACTIVE stop
uninstall uninstall stop
UNINSTALLED STOPPING
42. OSGi
‣ Declarative Services
‣ Framework Launching
‣ Blueprint Blueprint Service
‣ Web Web Application Bundle
‣ JPA JTA JDBC......
43. OSGi
‣ Declarative Services
‣ Framework Launching
‣ Blueprint Blueprint Service
‣ Web Web Application Bundle
‣ JPA JTA JDBC......
44. ‣ Service Component Model
‣ OSGi
‣ xml Component Service
‣
‣ Java POJO OSGi
‣
45. ——
‣ Bundle Manifest
Bundle-ManifestVersion: 2
...
Service-Component: OSGI-INF/component.xml [, ...]*
‣ OSGI-INF/
<?xml version="1.0" encoding="UTF-8"?>
<scr:component name="bookstore-order" xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0">
<!-- -->
<implementation class="com.osgi.ds.OrderService"/>
<!-- -->
<service><provide interface="com.osgi.ds.IOrder"/></service>
<!-- -->
<reference interface="com.osgi.ds.ICart" bind="setCart" unbind="unsetCart"
policy="dynamic" cardinality="1..1"/>
</scr:component>
46. ——
‣ Enabled——
‣ Satisfied——
‣ Immediate Component——
‣ Delayed Component——
‣ Factory Component——
47. <=>%42.*%0$1-.*$0%*+$%#(45("$"*%#(")-120&*-("%&.%&%.$09-#$%-"%*+$%.$09-#$%0$1-.*0'%&
*+$%#(45("$"*%#(")-120&*-("7%?+$%.$09-#$%50(5$0*-$.%)(0%*+-.%0$1-.*0&*-("%#(".-.*%()
50(5$0*-$.%&.%/$)-"$/%-"%+), - & .)/0,12), %&)#%("%5&1$ @AB7
?+$%.*&*$%/-&10&4%-.%.+(:"%-"%C-120$%@@D7D7%
—— 3 & 4 ! , ) / 556 7 6 8 9 9 )* & $ % ) / : 1 9 21 " ) " % / : 1 " ( & 4 ! , $ % & 1 "
)(+=,*>+,(
6789:&8;&<3
‣ Enabled—— B&)/0&2
2,-$2.$&C B&)/0&2
D62,-$2.$&C
‣ Satisfied—— +=,*>+,( $.%CA6,0$)E
9.:&?<
!"#$"%&%'()*+&(!,-.&( /&-.010'*2&(3&12*-&4(3$&-*+*-0'*"%(5&
'&B$6C$69
‣ Immediate Component—— !"#$%&#'&()*+&#(&,*'$&(&-#./#0#+12314&4$#+14"*,5(0$*14#.&+12&'#545'&-#.&+05'&#$%&(�(
.54-6&'#5'*4,#*$7#$%&4#89:#'%156-#-&0+$*)0$&#$%0$#+12314&4$#+14"*,5(0$*14;#<%*'#0661='#89
!!"#$#2 3(4+5()-./'0/1(1,-
2&4$0$*14'#$1#&0,&(6/#(&+60*2#0+$*)0$&-#+12314&4$#+14"*,5(0$*14';
8%E$'%&**0-62*$%()%&%/$,&'$/%#(45("$"*%-.%*+$%/$,&'-"1%()%#,&..%,(&/-"1%&"/%(6F$#*%#0
‣ Delayed Component——
!"#$%&'(()*+ *+$%&#*-9&*-("%()%&%/$,&'$/%#(45("$"*%#(")-120&*-("%/($.%"(*%(##20%2"*-,%*+$0$%-.%&
,&-./&0'123425&56'1257"#$%.6"25
)(0%&%.$09-#$%(6F$#*7%8%#(45("$"*%-.%&%/$,&'$/%#(45("$"*%:+$"%-*%.5$#-)-$.%&%.$09-#$
*(0'%#(45("$"*%&"/%/($.%"(*%+&9$%*+$%!""#$!%&#%&**0-62*$%()%*+$%'(")(*#*&%$,$4
<1&'(:;&(1
2345674%789
‣ Factory Component—— <=>%42.*%0$1-.*$0%&%.$09-#$%&)*$0%*+$%#(45("$"*%#(")-120&*-("%6$#(4$.%.&*-.)-$/7%?
*+-.%.$09-#$%42.*%,((E%*(%(6.$09$0.%()%*+$%.$09-#$%0$1-.*0'%&.%-)%*+$%#(45("$"*I.%62"
B&-"#&4 B&-"#&4
*$0$/%*+-.%.$09-#$7%?+-.%.*0&*$1'%4&E$.%-*%5(..-6,$%*(%0$1-.*$0%.$09-#$.%:-*+(2*%#0$&*-"
D%40'*4+*&C 40'*4+*&C
)(0%*+$%62"/,$%&"/%,(&/-"1%#,&..$.3%*+$0$6'%&,,(:-"1%0$/2#*-("%-"%-"-*-&,-J&*-("%*-4
4$4(0'%)((*50-"*7
>8?7468>89 D%9&' B&-"#&4
4&12*-& D%40'*4+*&C
K+$"%<=>%0$1-.*$0.%*+$%.$09-#$%("%6$+&,)%()%&%#(45("$"*%#(")-120&*-("3%-*%42.*%&9(
6
9&'
4&12*-&+0-'"1,E(F77%
,(&/%*(%(##20%)0(4%*+$%#(45("$"*L.%62"/,$7%<=>%#&"%$".20$%*+-.%6'%0$1-.*$0-"1%&%-#
4&12*-&
"'G&1H*4&E(6
(6F$#*%:-*+%*+$%C0&4$:(0E%)(0%*+&*%.$09-#$7%M'%0$1-.*$0-"1%&%-#+.!'#/%'&(+0%(6F$#*3%*
&'(:;&(1
(6F$#*%-.%"(*%"$$/$/%2"*-,%*+$%-#+.!'#/%'&(+0%-.%#&,,$/%*(%50(9-/$%*+$%.$09-#$%(6F$#*7%
*+(C,%0#*-E
5-67=8
$0*-$.%)(0%*+-.%0$1-.*0&*-("%#(".-.*%()%*+$%#(45("$"*%50(5$0*-$.%&.%/$)-"$/%-"%+), - & .)/
1&B*%C*%9
@AB7
48. ‣ R4.2 API OSGi
‣ OSGi ——org.osgi.framework.launch.FrameworkFactory
‣ OSGi web listener OSGi
‣
Class<FrameworkFactory> factoryClass = ServiceLoader.load(FrameworkFactory.class);
FrameworkFactory factory = factoryClass.newInstance();
Map<Object, Object> conf;
......//
Framework framework=factory.newFramework(conf);
framework.init();
BundleContext bundleContext = framework.getBundleContext();
......// bundle
framework.start();
49. BluePrint
‣ BluePrint ——Spring Dynamic Modules-->Eclipse Gemini
‣ OSGi dependency injection
‣ OSGi
‣ POJO
‣ OSGI-INF/blueprint/
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
...
</blueprint>
50. 3&45"$,67689 :$0;,(%"5)%5"$
5&'(
BluePrint ——Bean
‣ Java 9
‣
',+7/&(1 0,.0&,18
‣ argument, property, scope
‣ className, factoryMethod, factoryComponent
!"!#$#" 45&'(6
!"#$G#%&2&%&$3.'$&$7#&-$/&-&(#'$+,$'#*'#,#-%#2$+-$%"#$$/&.#0&'.1.'.$+-%#'3&
<bean id="order" class="com.osgi.bs.OrderService" init-method="init"
destroy-method="destroy"> 2(3)(#&#'0&'.1.'.<$!&70# CBC<C$.-$*&(# BCI$*'.5+2#,$&-$.5#'5+#9$.3$%"#$'#
<argument value="1"/>
<argument value="2"/>
&-2$%"#$/&.#0&'.1.'.$+-%#'3&6#<$!"#$%&70#$.-0)$*'.5+2#,$&$,1//&')4$%"#$,./
%+.-,$7#%9##-$%"#$2+33#'#-%$3#&%1'#,$&'#$2+,61,,#2$+-$0&%#'$,#6%+.-,<
<property name="Description" value="This is the order"/>
</bean> <01/$,67686 :$0;,=0;04$",3$0%5"$'
:11,;571&).,)<=&/&(1 >8(1'? %&'()*&1'@'1' A&BC,;01;.(
"1 45 "16 !"#$+2$.3$&$%.*$0
51. BluePrint ——
<!-- -->
<service id="orderService" interface="com.osgi.bs.IOrderService" ref="order">
<service-properties>
<entry key="order.discount" value="0.8"/>
</service-properties>
</service>
<!-- -->
OrderService os = new OrderService(1, 2);
os.setDescription( "This is the order" );
Hashtable props = new Hashtable();
props.put("order.discount", "0.8");
bundleContext.registerService(com.osgi.bs.OrderService.class.getName(), os,
props);
52. BluePrint ——
<!--reference -->
<reference id="orderRef" interface="com.osgi.bs.IOrderService" timeout="1000"
availability="optional"/>
<bean id="orderClient" class="...">
<property name="order" ref="orderRef"/>
</bean>
<!--reference-list -->
<reference-list id="orderRefs" interface="com.osgi.bs.IOrderService"
availability="optional">
<reference-listener bind-method="bind" unbind-method="unbind">
<bean class="com.osgi.bs.ReferenceListener"/>
</reference-listener>
</reference-list>
53. BluePrint ——
<!--reference -->
<reference id="orderRef" interface="com.osgi.bs.IOrderService" timeout="1000"
availability="optional"/>
<bean id="orderClient" class="...">
List
<property name="order" ref="orderRef"/>
</bean>
List
<!--reference-list -->
<reference-list id="orderRefs" interface="com.osgi.bs.IOrderService"
availability="optional">
<reference-listener bind-method="bind" unbind-method="unbind">
<bean class="com.osgi.bs.ReferenceListener"/>
</reference-listener>
</reference-list>
54. BluePrint VS
‣
‣
‣ BluePrint Java
‣ R4.0 DS R4.2 BS
‣ DS BS
55. OSGi Web
‣ Web OSGi
✓ Modularity——
✓ Lifecycle—— | | |
✓ Services——
57. tion we have been using in Toast.
Bridged—In the Bridged approach, the coding and exposure model
same as in Solo, but here the OSGi framework is embedded into a w
OSGi Web
Servlets
‣
JSPs
✓ HttpService
✓ Bridged HTTP
OSGi
Java
Figure 19–1 Solo server-side configuration
58. tion we have been using in Toast.
Bridged—In the Bridged approach, the coding and exposure model
same as in Solo, but here the OSGi framework is embedded into a w
OSGi Web
Servlets
‣
!"#$$%&'()*+,-../00123%0454006%78%972:;0<28=2&:0>4;05?>?00@A>50#! JSPs
✓ HttpService
✓ Bridged 19.2 Embedding the Back End in a Web Application HTTP 323
OSGi
Servlets
Java
JSPs
Figure 19–1 Solo server-side configuration
HTTP
Lite HTTP Bridge
OSGiEquinox
Framework
Application Server
Figure 19–2 Bridged server-side configuration
59. ——WAB
‣ WAB——Web Application Bundle1.0 R4.2
‣ Bundle OSGi Web
‣ Servlet2.5 JSP2.1
Manifest-Version: 1.0
Import-Package: ...
...
Bundle-Version: 1.0
Bundle-Name: orderManager
Bundle-ClassPath: WEB-INF/lib/commons-logging.jar,WEB-INF/
classes
Web-ContextPath: /order
Bundle-ManifestVersion: 2
Bundle-SymbolicName: com.osgi.bs.order
60. Web Bundle Architecture
Web Application
Bundles
Bundles
Deploy Bundle Admin Console Bundle
Application Server/OSGi Runtime
JVM
61. Web Bundle Architecture
Web Application
Bundles
Bundles
Deploy Bundle Admin Console Bundle
Application Server/OSGi Runtime
JVM
62. ‣ Equinox—— OSGi Eclipse
‣ Gemini (Spring DM)—— R4.2
‣ Virgo (Spring DM Server)—— OSGi Application Server
‣ Felix—— OSGi
‣ Nuxeo—— CMS OSGi
63. Questions? Follow me at
twitter.com/sagacity
t.sina.com.cn/n/
Notas do Editor \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n