控制器(Controller) | ?實現的是MVC中C 那個組成部分。 |
處理器映射(Handler mapping) | 包含預處理器(pre-processor),后處理器(post-processor)和控制器的列表,它們在符合某種條件時才被執行(例如符合控制器指定的URL)。 |
視圖解析器(View resolvers) | 可以將視圖名解析為對應的視圖。 |
本地化解析器(Locale resolver) | 能夠解析用戶正在使用的本地化設置,以提供國際化視圖。 |
主題解析器(Theme resolver) | 能夠解析你的web應用所使用的主題,以提供個性化的布局。 |
上傳文件解析器(multipart file resolver) | 提供HTML表單文件上傳功能。 |
處理器異常解析器(Handler exception resolver(s)) | 可以將異常對應到視圖,或者實現更加復雜的異常處理代碼。 |
EJB 3.0 (JSR 220) Java Persistence API 1.0 (JSR 220) JSP 2.1 (JSR 245) JSF 1.2 (JSR 252) JAX-WS 2.0 (JSR 224) StAX 1.0 (JSR 173) JAXB 2.0 (JSR 222) Web Services Annotations 1.0 (JSR 181) Common Annotations 1.0 (JSR 250) SAAJ 1.3 maintenance | JTA 1.1 maintenance JavaMail 1.4 & JAF 1.1 maintenance JSTL 1.2 maintenance Java EE Mgmt maintenance JACC maintenance Servlet maintenance Java EE Deployment maintenance WSEE maintenance |
EJB2.0 | EJB3.0(JPA) | |
Business Interface | public inerface HelloWold extends EJBLocalObject{ Public String getResult(); } | 無需定義接口 |
映射配置文件 | 編寫EJB3 Deployment descriptor | 可選 |
EJB實現 | public class HelloWorldEntityBean implements HelloWold, EntityBean{ private int id; private String result; private EntityContext txt; public HelloWorldEntityBean(){} public void setEntityContext( EntityContext text ){ txt = text; } public String getResult(){ Return result; } public int getId(){ return id; } public void setResult( String result ){ this.result = result; } public String cretaeByName( String name ) throws EJBException{ ..... } } | @Entity @Table(name=”hellotable”) public class HelloWoldEntity{ @Id private int id; p private String result; public HelloWoldEntity(){} public String getResult(){ return result; } public int getId(){ return id; } public void setResult( String result ){ this.result = result; } } |
Java Persistence API(EJB3 Persistence) | Hiberante | |
配置文件 | 可選 | 需要 |
One-To-One配置 | 可選 | <one-to-one name="address" class="com.foo.Address" cascade="All" lazy="false"/> |
Java代碼 | public class Order{ @OneToOne(cascade=CascadeType.ALL,fetch=FetchType.LAZYL) Address address; ...... } | public class Order{ Address address; ...... } |
public interface EntityManager { public void persist(Object entity); publicT merge(T entity); public void remove(Object entity); public T find(Class entityClass, Object primaryKey); public T getReference(Class entityClass, Object primaryKey); public void flush(); public void setFlushMode(FlushModeType flushMode); public FlushModeType getFlushMode(); public void lock(Object entity, LockModeType lockMode); public void refresh(Object entity); public void clear(); public boolean contains(Object entity); public Query createQuery(String ejbqlString); public Query createNamedQuery(String name); public Query createNativeQuery(String sqlString); public Query createNativeQuery(String sqlString, Class result- Class); public Query createNativeQuery(String sqlString, String result- SetMapping); public void close(); public boolean isOpen(); public EntityTransaction getTransaction(); }
<entity-manager> <name>myEntityManager>/name> <provider>com.redsoft.ejb3.PersistenceProviderImpl>/provider> <class>com.redsoft.samples.HelloEntityBean>/class> <properties> <property name="ConnectionDriverName" value="com.mysql.jdbc.Driver"/> <property name="ConnectionURL" value="jdbc:mysql://localhost/EJB3Test"/> <property name="ConnectionUserName" value="ejb3"/> <property name="ConnectionPassword" value="ejb3"/> >/properties> </entity-manager> }
public class HelloWorld { public static void main( final String[] args ){ /* * Obtain an EJB3 entity manager */ final EntityManagerFactory emf = Persistence.createEntityManagerFactory(); final EntityManager entityManager = emf.createEntityManager(); // Construct a HelloEntityBean final HelloEntityBean hello = new HelloEntityBean( 1, "foo" ); EntityTransaction trans = entityManager.getTransaction(); trans.begin(); entityManager.persist( hello ); trans.commit(); System.out.println( "Successfully persist hello: " + hello ); // Look up the HelloEntityBean by primarky key final HelloEntityBean anotherHello = entityManager.find( HelloEntityBean.class, new Integer( hello.getId() ) ); System.out.println( "Found hello: " + anotherHello ); // close the EntityManager entityManager.close(); emf.close(); } }
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "file://spring-beans.dtd"> <beans> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName"><value>com.mysql.jdbc.Driver</value></property> <property name="url"><value>jdbc:mysql://localhost/EJB3Test</value></property> <property name="username"><value>ejb3</value></property> <property name="password"><value>ejb3</value></property> </bean> <bean id="entityManagerFactory" class="org.springframework.orm.ejb3.LocalEntityManagerFactoryBean"> <property name="persistenceInfo"><ref local="persistenceInfo"/></property> </bean> <bean id="persistenceInfo" class="com.redsoft.ejb3.PersistenceInfoImpl"> <property name="nonJtaDataSource"><ref local="dataSource"/></property> <property name="entityManagerName"><value>myEntityManager</value></property> <property name="persistenceProviderClassName"> <value> com.redsoft.ejb3.PersistenceProviderImpl </value> </property> <property name="entityClassNames"> <list> <value>com.redsoft.ejb3.spring.Child</value> <value>com.redsoft.ejb3.spring.Father</value> </list> </property> <property name="properties"> <props> <prop key="javax.jdo.PersistenceManagerFactoryClass"> com.redsoft.jdo.PersistenceManagerFactoryImpl </prop> </props> </property> </bean> <bean id="transactionManager" class="org.springframework.orm.ejb3.EJB3TransactionManager" singleton="true"> <property name="entityManagerFactory"> <ref local="entityManagerFactory" /> </property> </bean> <bean id="dao" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" singleton="true"> <property name="transactionManager"> <ref local="transactionManager" /> </property> <property name="target"> <bean class="com.redsoft.ejb3.spring.DAOImpl"> <property name="entityManagerFactory"> <ref local="entityManagerFactory" /> </property> </bean> </property> <property name="transactionAttributes"> <props> <prop key="save*">PROPAGATION_REQUIRED</prop> <prop key="remove*">PROPAGATION_REQUIRED</prop> <prop key="del*">PROPAGATION_REQUIRED</prop> <prop key="update*">PROPAGATION_REQUIRED</prop> <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="query*">PROPAGATION_REQUIRED,readOnly</prop> </props> </property> </bean> </beans>
<MenuConfig>
? <Displayers>
??? <Displayer?? name="DropDown"
???????????????? type="net.sf.navigator.displayer.DropDownMenuDisplayer"/>
??? <Displayer?? name="Simple"
???????????????? type="net.sf.navigator.displayer.SimpleMenuDisplayer"/>
??? <Displayer?? name="CoolMenu"
???????????????? type="net.sf.navigator.displayer.CoolMenuDisplayer"/>
??? <Displayer?? name="CoolMenu4"
???????????????? type="net.sf.navigator.displayer.CoolMenuDisplayer4"/>
??? <Displayer?? name="MenuForm"
???????????????? type="net.sf.navigator.example.PermissionsFormMenuDisplayer"/>
??? <Displayer?? name="ListMenu"
???????????????? type="net.sf.navigator.displayer.ListMenuDisplayer"/>
??? <Displayer?? name="TabbedMenu"
???????????????? type="net.sf.navigator.displayer.TabbedMenuDisplayer"/>
??? <Displayer?? name="Velocity"
???????????????? type="net.sf.navigator.displayer.VelocityMenuDisplayer"/>
? </Displayers>
? <Menus>
?
? </Menus>
</MenuConfig>