Spring Integration in Action
Source code: www.manning.com/SpringIntegrationinAction
A message is passed through a channel from one endpoint to another endpoint.
A message consists of a single payload and zero or more headers.
The channel implementation manages the details of how and where a message is delivered but
shouldn’t need to interact with the payload of a message.
Two endpoints can exchange messages only if they’re connected through a channel.
Channels can be categorized based on two dimensions: type of handoff and type of
delivery. The handoff can be either synchronous or asynchronous, and the delivery
can be either point-to-point or publish-subscribe.
Connections to the application or the outside world are also endpoints, and these connections take
the form of channel adapters, messaging gateways, or service activators.
A Channel Adapter connects an application to the messaging system.
In Spring Integration, a Messaging Gateway iss a connection that’s specific to bidirectional messaging.
A Service Activator is a component that invokes a service based on an
incoming message and sends an outbound message based on the return value of this service invocation.
The main idea behind IoC and the Spring Framework itself is that code should be
as simple as possible while still supporting all of the complex requirements of enterprise
applications. To accomplish that goal, the responsibility of controlling those complexities should be
inverted from the application code to a framework.
Wednesday, October 29, 2014
Tuesday, October 7, 2014
有道口语大师
-It's time to get off work.
-OK, let me grab my coat.
-what did you have in mind?
-I need to sleep on it. --考虑一晚上再给你答案
-I'd like to make a reservation, please. The name is Anthony Cooper.
-Does the price include the breakfast?
-Yes Sir, We provide complimentary breakfast everyday.
-What else does the price include?
-Excuse me, could you tell me where can I get to the washroom?
-Hello, I'm looking for the new bookstore. Could you tell me how to get there?
-Is it far? Should I take a bus?
-Is it far? Can I get there on foot?
-Is it far? Should I take the metro?
-How long will it take if I walk?
-I'd like to book a table.
-OK, let me grab my coat.
-what did you have in mind?
-I need to sleep on it. --考虑一晚上再给你答案
-I'd like to make a reservation, please. The name is Anthony Cooper.
-Does the price include the breakfast?
-Yes Sir, We provide complimentary breakfast everyday.
-What else does the price include?
-Excuse me, could you tell me where can I get to the washroom?
-Hello, I'm looking for the new bookstore. Could you tell me how to get there?
-Is it far? Should I take a bus?
-Is it far? Can I get there on foot?
-Is it far? Should I take the metro?
-How long will it take if I walk?
-I'd like to book a table.
Sunday, September 28, 2014
行车记录仪优影U68说明书
优影U68说明书
1. 查看视频或图片
连按两下O键,用上下键选择视频,按电源键最大化该视频,再按电源键播放。该视频最大化时按M键可删除或锁定该视频。
2. 锁定视频
录像状态下按M键
3. 格式化
格式化会删除所有文件,包括锁定文件
1. 查看视频或图片
连按两下O键,用上下键选择视频,按电源键最大化该视频,再按电源键播放。该视频最大化时按M键可删除或锁定该视频。
2. 锁定视频
录像状态下按M键
3. 格式化
格式化会删除所有文件,包括锁定文件
Friday, September 19, 2014
The performance improvement for P3
The performance improvement for P3
1 Used indexed collection to do the search and filter (cqengine)
2 Parallel processing (multi threading) for the dump file retrievement
3 Compress recon report and save blob into the database instead of clob and before show, unzip and show
4 Reduce the invocation and intercommuncation between the system and AC/DB
many times sql invocation against DB and the system to a few invocations on Oracle PL/SQL procedure/function
optimize the execution order (get batch result on AC/DB, collect the result in DB, and finally process them from Java)
Use the listagg instead of processing on Java side
getHolidayCount (currency,asofdate,maturityDate)
reduce the candidate size from SQL side instead of Java side (for FutureRollManager
5 Cache the query result from AC and database
1 Used indexed collection to do the search and filter (cqengine)
2 Parallel processing (multi threading) for the dump file retrievement
3 Compress recon report and save blob into the database instead of clob and before show, unzip and show
4 Reduce the invocation and intercommuncation between the system and AC/DB
many times sql invocation against DB and the system to a few invocations on Oracle PL/SQL procedure/function
optimize the execution order (get batch result on AC/DB, collect the result in DB, and finally process them from Java)
Use the listagg instead of processing on Java side
getHolidayCount (currency,asofdate,maturityDate)
reduce the candidate size from SQL side instead of Java side (for FutureRollManager
5 Cache the query result from AC and database
Sunday, September 14, 2014
Computational Investing, Part I Week 1 note
Computational Investing, Part I Week 1 note
1. Portfolio manager: the constant management fee, less than 1%, not related to the performance.
Hedge fund: two and twenty. 2% of the total amount plus 20% of the return
2. Common metrics for the hedge fund performance:
annual return, risk: standard deviation of return, volatility
3. Return|Sharpe|STDEV|Draw-down|Co
4. short sell: borrow the stock and sell them immediately to the market, buy them back and return them in the near future.
standard deviation of the return is the most common measure of risk.
Monday, September 8, 2014
Pro Spring 3 note
Pro Spring 3
1. Using XML file can externalize all configuration from Java code, while annotations allow the
developer to define and view the DI setup from within the code. Spring also supports a mix of the two
approaches in a single ApplicationContext (the XML file configuration will override the annotation
ones).
One common approach nowadays is to define the application infrastructure (e.g., data source,
transaction manager, JMS connection factory, JMX, etc.) in XML file, while defining the DI configuration
(injectable beans and beans’ dependencies) in annotations.
2.
<context:annotation-config/>
<context:component-scan base-package="com.apress.prospring3.ch4.annotation" />
The <context:annotation-config> tag tells Spring to scan the codebase for dependency
requirements, while the <context:component-scan> tag tells Spring to scan the code for injectable beans
under the package (and all its subpackages) specified. In the <context:component-scan> tag, multiple
packages can be defined by using either a comma, a semicolon, or a space as the delimiter.
3.
you use Spring’s @Service annotation to specify that the bean
provides services that other beans may require, passing in the bean name as the parameter. When
bootstrapping Spring’s ApplicationContext with the XML configuration in Listing 4-15, Spring will seek
out those components and instantiate the beans with the specified names.
4.
Instead of the @Autowired, you can also use the @Resource(name="messageProvider") to achieve the
same result. The @Resource is one of the annotations in the JSR-250 standard that defines a common set of Java
annotations for use on both JSE and JEE platforms. Different from @Autowired, the @Resource annotation
supports the name parameter for more fine-grained DI requirements.
5.
Basically, using
@Component has the same effect as @Service. Both annotations were instructing Spring that the annotated
class is a candidate for autodetection using annotation-based configuration and classpath scanning.
However, since the InjectSimpleConfig class is storing the application configuration, rather than
providing a business service, using @Component makes more sense. Practically, @Service is a
specialization of @Component, which indicates that the annotated class is providing a business service to
other layers within the application.
6.
You may wonder why the annotation @Resource was used instead of @Autowired. It’s because the
@Autowired annotation is semantically defined in a way that it always treats arrays, collections, and maps as
sets of corresponding beans, with the target bean type derived from the declared collection value type. So, for
example, if a class has an attribute of type List<Oracle> and has the @Autowired annotation defined, Spring will
try to inject all beans of type Oracle within the current ApplicationContext into that attribute (instead of the
<util:list> declared in the configuration file), which will result in either the unexpected dependencies being
injected or Spring throwing an exception if no bean of type Oracle was defined. So, for collection type injection,
we have to explicitly instruct Spring to perform injection by specifying the bean name, which the @Resource
annotation supports.
7.
The following are the bean scopes that are supported as of version 3.1:
• Singleton: The default singleton scope.
• Prototype: A new instance will be created by Spring when requested by application.
• Request: For web application use. When using Spring MVC for web application,
beans with request scope will be instantiated for every HTTP request and then
destroyed when the request is completed.
• Session: For web application use. When using Spring MVC for web applications,
beans with session scope will be instantiated for every HTTP session and then
destroyed when the session is over.
8.
@PostConstruct/@PreDestroy. Starting from Spring 2.5, Spring also supports JSR-250 annotations to specify the
method that Spring should call if the corresponding annotation relating to the bean’s life cycle exists in
the class.
The easiest way to take advantage of this mechanism is to use the
AbstractApplicationContext’s registerShutdownHook() method. The method automatically instructs
Spring to register a shutdown hook of the underlying JVM runtime.
1. Using XML file can externalize all configuration from Java code, while annotations allow the
developer to define and view the DI setup from within the code. Spring also supports a mix of the two
approaches in a single ApplicationContext (the XML file configuration will override the annotation
ones).
One common approach nowadays is to define the application infrastructure (e.g., data source,
transaction manager, JMS connection factory, JMX, etc.) in XML file, while defining the DI configuration
(injectable beans and beans’ dependencies) in annotations.
2.
<context:annotation-config/>
<context:component-scan base-package="com.apress.prospring3.ch4.annotation" />
The <context:annotation-config> tag tells Spring to scan the codebase for dependency
requirements, while the <context:component-scan> tag tells Spring to scan the code for injectable beans
under the package (and all its subpackages) specified. In the <context:component-scan> tag, multiple
packages can be defined by using either a comma, a semicolon, or a space as the delimiter.
3.
you use Spring’s @Service annotation to specify that the bean
provides services that other beans may require, passing in the bean name as the parameter. When
bootstrapping Spring’s ApplicationContext with the XML configuration in Listing 4-15, Spring will seek
out those components and instantiate the beans with the specified names.
4.
Instead of the @Autowired, you can also use the @Resource(name="messageProvider") to achieve the
same result. The @Resource is one of the annotations in the JSR-250 standard that defines a common set of Java
annotations for use on both JSE and JEE platforms. Different from @Autowired, the @Resource annotation
supports the name parameter for more fine-grained DI requirements.
5.
Basically, using
@Component has the same effect as @Service. Both annotations were instructing Spring that the annotated
class is a candidate for autodetection using annotation-based configuration and classpath scanning.
However, since the InjectSimpleConfig class is storing the application configuration, rather than
providing a business service, using @Component makes more sense. Practically, @Service is a
specialization of @Component, which indicates that the annotated class is providing a business service to
other layers within the application.
6.
You may wonder why the annotation @Resource was used instead of @Autowired. It’s because the
@Autowired annotation is semantically defined in a way that it always treats arrays, collections, and maps as
sets of corresponding beans, with the target bean type derived from the declared collection value type. So, for
example, if a class has an attribute of type List<Oracle> and has the @Autowired annotation defined, Spring will
try to inject all beans of type Oracle within the current ApplicationContext into that attribute (instead of the
<util:list> declared in the configuration file), which will result in either the unexpected dependencies being
injected or Spring throwing an exception if no bean of type Oracle was defined. So, for collection type injection,
we have to explicitly instruct Spring to perform injection by specifying the bean name, which the @Resource
annotation supports.
7.
The following are the bean scopes that are supported as of version 3.1:
• Singleton: The default singleton scope.
• Prototype: A new instance will be created by Spring when requested by application.
• Request: For web application use. When using Spring MVC for web application,
beans with request scope will be instantiated for every HTTP request and then
destroyed when the request is completed.
• Session: For web application use. When using Spring MVC for web applications,
beans with session scope will be instantiated for every HTTP session and then
destroyed when the session is over.
8.
@PostConstruct/@PreDestroy. Starting from Spring 2.5, Spring also supports JSR-250 annotations to specify the
method that Spring should call if the corresponding annotation relating to the bean’s life cycle exists in
the class.
The easiest way to take advantage of this mechanism is to use the
AbstractApplicationContext’s registerShutdownHook() method. The method automatically instructs
Spring to register a shutdown hook of the underlying JVM runtime.
note on boating license
Please take note of the following age restrictions:
- Children under 12 years of age may only operate a boat with a motor of up to 10 hp, unless accompanied and directly supervised by someone 16 years of age or older.
- Persons 12 to 15 years of age may only operate a boat with a motor of up to 40 hp, unless accompanied and directly supervised by someone 16 years of age or older.
- The minimum age for operating a personal watercraft (i.e., Sea-Doo®, Jet Ski®) is 16 years of age
All pleasure craft principally maintained or operated in Canada propelled by motors of 10 horsepower (7.5 kW) or greater must be licenced.
According to the Canada Shipping Act 2001, all pleasure craft (with OR without a motor) manufactured in or imported into Canada after August 1, 1981, must be permanently marked with a Hull Identification Number (HIN).
If the ownership of a licensed pleasure craft is transferred, the former owner must sign the transfer form that is printed on the reverse side of the licence and deliver it to the new owner. The new owner will then be required to submit an application form along with the required documentation by mail to The Pleasure Craft Licensing Centre to transfer the pleasure craft licence.
It is the responsibility of the boat operator to ensure that there are properly fitted PFDs onboard for all passengers.
For a personal flotation device to be approved in Canada, it must have a label stating that it has been approved by Transport Canada, the Canadian Coast Guard, Fisheries and Oceans Canada, or any combination of these three organizations.
PFDs differ from lifejackets in that they may not turn a wearer face-up when in the water. There is also no colour requirement for an approved PFD. in order for a lifejacket to be approved, it must be red, orange or yellow in colour, and be designed to turn the wearer face-up when in the water.
- Slowly lower the anchor from the bow, rather than the stern, to avoid capsizing or swamping.
- Secure the line to a bow cleat. Never tie the line to the stern; the additional weight could bring on water.
Any anchored vessel of less than 50m (164 feet) in length must display an all-round white light where it can be best seen, between the hours of sunset and sunrise.
Boats no more than 6m in length:
- Must carry a watertight flashlight; OR
- Three Canadian-approved pyrotechnic distress signals (flares), other than smoke signals.
Visual signals are not required onboard any boat that is not motorized and 6m or less in length.
Sailboards, Kiteboards, Paddleboats, Watercycles, and Sealed-Hull Sit-on-Top Kayaks:
If every person onboard the pleasure craft is wearing a properly fitted, approved PFD or lifejacket, the only required equipment is:
- A sound signalling device; and
- A watertight flashlight if operated at night or during periods of reduced visibility.
Human-powered vessels:
Must carry either a bailer; OR
A manual bilge pump; OR
Bilge-pumping arrangements
Subscribe to:
Posts (Atom)