4,4 平, 取其中三个,和剩下的4个中的三个对称,平,余下的1个找到了,
不平,哪三个球有异球,且是轻是重也明白了,再一次搞定。
A4,B4 不平, 则余下4球正常。
再组合
A4 = A3+A1 , B4= B3+B1
正常4球中取C3
A3+ B1 对 C3+A1
平, B3 有问题,且知道异常球轻重, 再一次搞定。
不平,维持不变, A3 有问题,且知道轻重, 再一次搞定。
不平,轻重指示反过来了,A1,B1 有问题,在取一个正常球,一次搞定。
1. Dependency Injection
EJB3.x --Can inject anything in the container including EJBs, data sources, JMS resources and JPA resources
Spring --Can inject almost anything including lists, maps, properties and JNDI resources.
2.Transaction Management
EJB3.x --Works right out of the box, but only JTA is supported
Spring --Have to configure it to make it work, but supports a number of strategies including JTA, JDBC and Hibernate
3. Persistence
EJB3.x -- Tightly integrated through JPA. JPA is an API not an implementation. We could use JPA with different vendor persistence ORM implementation like Hibernate, Eclipselink (recommended by Oracle for EE6), Toplink (only available of JEE5 and less)
Spring --Framework support for JPA, Hibernate, JDBC, iBatis
4. State management
EJB3.x --Robust support through Stateful Session Beans and Extended Persistence Context
Spring --Indirect support dependent on web container session management
5. Web services
EJB3.x --Seamless support for JAX-WS 2.0
Spring --Poor direct support, best integration available is via configuring XFire for registered beans.
6. Messaging
EJB3.x --Supported out of the box through Message Driven Beans.
Spring --Need to add configuration for message listeners. However, JMSTemplate adds nice abstraction over JMS.
7. AOP
EJB3.x --Simple but limited support through interceptors.
Spring --Robust support through AspectJ and Spring AOP alliance.
8. Security
EJB3.x --Integrated support for declarative and programmatic security through JAAS.
Spring --Must add and configure Acegi security. However,support beyond JAAS is possible through Acegi.
9. Scheduling.
EJB3.x --Simple scheduling possible through EJB Timer service
Spring --Must add and configure Quartz for scheduling.
10.Remoting
EJB3.x --Integrated support through Session Bean remote interfaces. Supports distributed transactions and security.
Spring --Remoting support may be added via configuration. Remote transactions and security are not supported. However protocols other than RMI such as Hessian and Burlap are supported.
11. Server Container Services:
EJB3 run inside an EJB container inside an application server as middle ware components and there for provided all the application server features.
Spring beans run inside a web server there for limited to the web server abilities.
摘要: For some situation, we need to implement a FIFO execution model using multiple threads, like the following watchdog scenario.A postman delivers books to the door from time to time. A puppy (watchdog) ...
阅读全文
本文仅记录对“Java Persistence on the Grid: Approaches to Integration”这篇文章的观后感。原文请见http://opensource.sys-con.com/node/951117
原文作者指出的东东我也一直在考虑,所以读来于我心有戚戚焉。文章写的是JPA,放之别的persistence mechanism也是一样。
此处的grid其实就是一个distributed cache,总不由让我想起memcached,但是memcached在功能上比grid有点单薄。关键点是每个grid上都持有unique的data,彼此之间不需沟通,如此,当此grid有了update时,它只需要通知它的backup,不必理会其他的grid,这样就保证了linear scalability。
本文讨论了两种架构模式:
1)以database为主,grid为辅。每次的读操作都是先对grid进行,没有命中再进行数据库查询。但是写操作必须以数据库为准,如果DB的写操作失败,grid的也必须失败。这个transaction由application发起,application同时负责对grid和db的操作。
2)以grid为主,database为辅。application只管对grid的操作,grid负责自身的crud,同时,对update发送到DB(注意一定要是异步,不然grid慢死)。这样的好处就是bypass database,throughput应该有所增加。但是grid上要增加异步update db的逻辑。
I have been playing with Google Application Engine for the past two days, trying to build a tool for my wife, so that she can get notification emails when, for example, a price drop happens for the burberry handbag she always wants from neimanmarcus (did I spell it right?) website.
Well, I kept encountering technical issues with GAE.
1) When working with the GAE plugins in eclipse, it seems that I cannot include any third party external jars into the project. It will compile corretly, but throws a classnotfoundexception in runtime, when the third party jar is going to be used. My alternative is to include all the source files for the 3rd party jar into the project.
2) No thread creation on the server side. It looks like GAE does not allow thread creation inside the server side servlet. Because my application needs to monitor a website on an interval base, I planned to spawn a thread to achieve that, although I would do it differently if I have total control on the backend. It gives me an access exception (if I remember it correctly) when I tried to do so.
3) Because of #2, I have to move the polling part inside the same thread which receives the async request on the server side. After maybe 30 seconds (the thread sleeps for 20 seconds), a DeadlineExceededException is throw. I think GAE does not allow a servlet thread to be executed more than 30 seconds.
With that, I decided not to build this application on GAE. I am not saying GAE is bad, but it just does not meet the technical requirement for this specific type of application.
摘要: 10月18、19号两天参加了在美国中部nebraska州举行的Heartland Developer Conference, 这是一个尚是区域型的MS开发者集会,一年一次,主要是针对我们这块前不着村后不着店的美中部地区,但是这次请到了Scott Guthrie, Ron Jacobs等重量级人物,怎么着也要去瞧两眼。
阅读全文
摘要: 最近有个asp.net程序,需要长时间查 询数据库,千万级,且经常有reports同时运行,所以搞不好一个submit就要等1,2个小时。我把sql timeout设成无限,http request timeout设成12个小时,但是不知为什么在production server上总是运行了1.5小时后就出现page can not be displayed,后台的query则还在运行。但是在我的...
阅读全文
摘要: The backend database is sql server 2000.1) in web.config, set encoding to utf-82) in sql server, set field type to nchar, nvarchar or ntext3) in the application data access layer, if using stored proc...
阅读全文
摘要: c#用委托来实现事件通知机制。委托相当与c++函数指针。整个过程涉及一个呼叫者,一个被呼叫者,还有就是这个委托。- 实现步骤有以下几步: 1. 申明委托, 2.定义呼叫者和调用的函数, 3.定义被呼叫者和具体实现的函数(被调用的函数)1.申明委托 ,在包里或者类里,publicCode highlighting produced by Actipro CodeHighlighter (freewa...
阅读全文