- 浏览: 545001 次
- 性别:
- 来自: 西安
文章分类
- 全部博客 (251)
- UML/RUP/软件工程 (0)
- DDD:领域驱动设计 (1)
- IaaS/Paas/SaaS (1)
- Hadoop/YARN (10)
- PBDP项目 (2)
- OSGi-基础 (7)
- OSGi-Aries (2)
- OSGi-SpringDM (32)
- Oracle/MySQL/SS (8)
- Felix/Equinox/Bnd (14)
- Virgo Server/Gemini (7)
- Weblogic/JBoss/Tomcat (10)
- ActiveMQ (14)
- Camel (1)
- Spring Roo/Eclipse (7)
- Java/JSP/JSF (10)
- Maven (19)
- ESB-Mule (1)
- ESB-ServiceMix (18)
- SOA/SCA/SDO (12)
- WebService/RESTful (17)
- JS/jQuery/ExtJS (4)
- Spring/JPA/MVC (15)
- SpringSecurity (5)
- BPM/jBPM (3)
- Hudson/SVN/CI (0)
- LinuxOS/虚拟化 (25)
- Office/OpenOffice (1)
- 项目管理 (5)
- POI/jFreeChart (1)
最新评论
-
panamera:
请问JMS Transport 发布的webservice 是 ...
CXF 提供的Service Transport-JMS Transpor -
jianyi296:
where is attachment.
CXF WebService Dynamic Client -
hj01kkk:
您好,我用jdbc-user-service为什么每次验证时都 ...
SpringSecurity笔记3-Authenticating Users:Authenticaton Strategy -
wufenglin1231:
你好,我在实现Mapping exceptions to re ...
RESTful 异常处理 -
xchd:
[echo] Project: common
[echo ...
Hive安装配置学习笔记
■ Action-based web frameworks
■ Component-driven frameworks
■ AJAX-based frameworks
■ Web services
Action-based web frameworks are responsible for selecting the appropriate actions to handle requests.Actions are responsible for extracting parameters from requests, executing the
requests, and building responses.
1. Using Spring DM with action-based frameworks
The central entity of action-based web frameworks is the action entity. This kind of entity is
responsible for handling requests and executing functionality based on the requests, typically
by using external components.When configuring Spring support for this kind of framework,
there are two main steps:
(1)Specify the OSGi web application context from Spring DM to use the osgi namespace.
This
allows you to define and reference OSGi services from within Spring application contexts.
(2)Inject OSGi services configured through Spring DM info the actions of the application.
This
can be done using classic or annotation-based dependency injection.
2. Using Spring MVC with Spring DM
Bundles related to Spring MVC, available from the SpringSource EBR:
org.springframework.web.servlet :2.5.6
com.springsource.javax.servlet :2.5.0
com.springsource.javax.servlet.jsp :2.1.0
com.springsource.javax.servlet.jsp.jstl: 1.1.2
com.springsource.org.apache.taglibs.standard :1.1.2
spring-osgi-web :1.2.0
(1)CONFIGURING SPRING MVC FOR SPRING DM
Spring MVC uses two Spring application contexts for its configuration:
The first one
corresponds to Spring MVC’s association with the web application; it’s used to
configure entities independent of web-related concerns, such as logic or business entities.
If you’re using Spring DM, this context is also where you’d put OSGi service references to
business services. To use Spring DM’s service support, we need to specify
OsgiBundleXmlWebApplicationContext, which is the OSGi-aware application context provided
by Spring DM.
The other Spring application context corresponds to the Spring frontend controller, the
DispatcherServlet. This context is a child context of the web application context, and it has
access to all artifacts configured in its parent. We can also use Spring DM at this level to
reference services by specifying an OSGi-aware application context class.
Configuring the Spring web application context:
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee
/web-app_2_4.xsd"
version="2.4">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/osgi-context.xml</param-value>
</context-param>
<context-param>
<param-name>contextClass</param-name>
<param-value>
org.springframework.osgi.web.context.support.OsgiBundleXmlWebApplicationContext
</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>2</load-on-startup>
<init-param>
<paramname>contextClass</param-name>
<param-value>
org.springframework.osgi.web.context.support
.OsgiBundleXmlWebApplicationContext</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>
springmvc-servlet.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:component-scan base-package="com.manning.sdmia.web.springmvc"/>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
<bean class="org.springframework.osgi.extensions.annotation
.ServiceReferenceInjectionBeanPostProcessor"/>
</beans>
(2)USING ANNOTATION-BASED SUPPORT
Configuring Spring MVC entities:
<context:component-scan base-package="com.manning.sdmia.web.springmvc"/>
<!--Activates annotationbased injection for services-->
<bean class="org.springframework.osgi.extensions.annotation
.ServiceReferenceInjectionBeanPostProcessor"/>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
Implementing the Spring MVC controller:
@Controller
public class ContactsController {
private ContactService contactService;
@ServiceReference
public void setContactService(ContactService contactService) {
this.contactService = contactService;
}
@RequestMapping("/contacts.do")
public ModelMap getContacts() {
List<Contact> contacts = contactService.getContacts();
return new ModelMap("contacts", contacts);
}
}
需Import的Package:
Import-Package: (...)
org.springframework.stereotype;version="2.5.6",
org.springframework.ui;version="2.5.6",
org.springframework.web.bind.annotation;version="2.5.6",
org.springframework.web.servlet.view;version="2.5.6"
(3)CONFIGURING AND USING JSTL
Packages to import for Spring MVC:
Import-Package: (...)
javax.servlet.http;version="2.4.0",
javax.servlet.resources;version="2.0.0",
javax.servlet.jsp;version="2.0.0",
javax.servlet.jsp.jstl.core;version="1.1.2",
javax.servlet.jsp.jstl.fmt;version="1.1.2",
javax.servlet.jsp.jstl.tlv;version="1.1.2",
org.apache.taglibs.standard.resources;version="1.1.2",
org.apache.taglibs.standard.tag.common.core;version="1.1.2",
org.apache.taglibs.standard.tag.rt.core; version="1.1.2",
org.apache.taglibs.standard.tei;version="1.1.2",
org.apache.taglibs.standard.tlv;version="1.1.2"
Implementing a JSTL view in a JSP file:
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<html>
<body>
(...)
<c:forEach items="${contacts}" var="contact">
<c:out value="${contact.firstName}"/>
<c:out value="${contact.lastName}"/>
</c:forEach>
(...)
</body>
</html>
3. MVC 2 pattern
The MVC pattern aims to keep responsibilities separate when implementing UIs. The model
corresponds to the data to be displayed, and the view to the UI. The controller intercepts
user requests, executes business services, and then forwards the results to the view.
Although this pattern is convenient, it can be cumbersome to implement. That’s why a new
version has been developed based on a controller called the front controller, which is
responsible for forwarding requests to the right handling entity. The rest of the pattern
remains as it was before. All current Java web frameworks base their implementations
on the second version of this pattern.
评论
请直接参考Eclipse Virgo项目的Samples Demo:
http://www.eclipse.org/virgo/samples/
这个例子比较完善。
发表评论
-
SpringDM笔记31-Testing with OSGi and SpringDM
2011-11-22 10:27 12461. 创建一个SpringDM测试类 SpringD ... -
SpringDM笔记30-OSGi中使用SSL/STL
2011-11-21 11:55 1319SSL:Secure Sockets Layer ... -
SpringDM笔记29-Require-Bundle与Import-Package的区别
2011-11-21 10:31 2238具体可参考:http://www.osgi.org/bl ... -
SpringDM笔记28-OSGi Bundle Activities with Spring-DM
2011-11-17 10:19 1159OSGi框架中也支持搞层次的模块交互:bundles.例如 ... -
SpringDM笔记28-Spring And OSGi:Layers of Integration
2011-11-15 11:00 11761. Application Design:Service和B ... -
SpringDM笔记27-Extending The Stand Extender and Configure
2011-09-02 09:38 8691. -
SpringDM笔记25-Using AJAX frameworks with Spring DM:GWT
2011-09-01 08:53 12011. Using Spring DM with AJAX fr ... -
SpringDM笔记23-Using the open EntityManager in view pattern实现延迟加载
2011-08-30 09:27 15671. The open EntityManager in vi ... -
SpringDM笔记22-Transactions Support With SpringDM
2011-08-29 21:24 12111. Spring’s transactional suppo ... -
SpringDM笔记21-Using ORM within OSGi with Spring DM
2011-08-25 10:31 2096Version 1.Object/relational ma ... -
SpringDM笔记20-Using JDBC within OSGi with Spring DM
2011-08-25 09:08 1776The public API for interact ... -
SpringDM笔记19-SpringDM如何处理OSGi应用的动态行为
2011-08-24 08:51 1143ServiceTracker 1. Dealing ... -
SpringDM笔记18-Designing OSGi Enterprise Applications
2011-08-22 11:08 11221. Organizing OSGi components ... -
SpringDM笔记17-Handling Collections of OSGi Services
2011-08-20 09:12 15421.Configuring collections:the l ... -
SpringDM笔记16-处理OSGi服务的动态性:事件
2011-08-19 09:51 17801. Service registration and unr ... -
SpringDM笔记15-通过声明特定的属性注册和引用服务
2011-08-18 11:01 14081. Configuration for registerin ... -
SpringDM笔记14-The thread context classloader 及在OSGi中的运用
2011-08-18 10:40 22481. Using the thread context cla ... -
SpringDM笔记13-OSGi服务注册与引用
2011-08-18 09:28 34501. Combining OSGi services and ... -
SpringDM笔记12-Spring DM’s web Extender运行机制
2011-08-17 11:04 2088SpringDM把一个WAR作为一个Bundle, 其实 ... -
SpringDM笔记11-Hard dependencies on the OSGi environment
2011-08-17 10:50 1414Any bean in a Spring DM app ...
相关推荐
org-netbeans-modules-web-frameworks-struts2lib-v2_2_3.nbm
Building-Web-Applications-with-Python-and-Neo4j-Develop-exciting-real-world-Python-based-web-applications-with-Neo4j-using-frameworks-such-as-Flask-Py2neo-and-Django.pdf
Chapter 1: Web 2.0, Python, and Frameworks 3 The Starting Line 4 What’s Web 2.0? 4 The History of Application Design for Content Creation (In One Easy Dose) 4 The Role of AJAX in Web 2.0 10 ...
ISO IEC TR 20000-12:2016 Information technology — Service management — Part 12:Guidance on the relationship between ISO IEC 20000-1:2011 and service management frameworks:CMMI-SVC- 完整英文电子...
Discover the key Spring framework-related technology standards such as Spring core, Spring-AOP, Spring data access frameworks, and Spring testing to develop robust Java applications easily and rapidly...
bc31---Borland C++ & Application Frameworks 3.1.zip
(可能很棒)解决Javascript问题的Web框架因为用两种语言编写一个Web项目令人沮丧,尤其是使用Javascript。 我们将在此处列出同构Web框架,这些框架允许编写交互式Web应用程序而无需使用Javascript。 奖励指向那些不...
JAX-WS-Web-Service-with-Apache-CXF-and-Spring-frameworks。
Using a problem-solution approach, Spring Boot 2 Recipes quickly introduces you to Pivotal's Spring Boot 2 micro-framework, then dives into code snippets on how to apply and integrate Spring Boot 2 ...
-- Be familiar with popular web development frameworks and tools, such as Struts, Spring, Hibernate. -- Good knowledge of database systems and development. -- Familiar with DB2 development tools and ...
“# Front-End-Web-UI-Frameworks-and-Tools-Bootstrap-4”
This book is for anyone wishing to learn to develop Java-based web applications with Spring MVC. Sample applications come as Spring Tool Suite and Eclipse projects. Table of Contents Introduction ...
Set up and build standalone and web-based projects using Spring Framework with Maven or Gradle Get familiar with JSP Form processing using Spring and Form Tag Library Develop RESTful API applications ...
Pro Spring MVC provides in-depth coverage of Spring MVC and Spring Web Flow, two highly customizable and powerful web frameworks brought to you by the developers and community of the Spring Framework....
leetcode中文版Go 库和框架 受 . 来自 . 内容 音频和音乐 用于处理音频的库。 最后更新:2021-06-20 ...14:24:56 2021-06-10 02:27:25 190 31 14 :musical_note: Go 的 ID3 解码和编码库 2016-05-15 18:36:5
One of the first (if not the first) books on the latest Spring 3.x, and the first Spring code Recipes book focused on Spring Web-tier development The Spring framework is growing. It has always been ...
敏捷网络框架的实用比较使用不同的 Web 框架开发的最小博客示例来比较它们。 比较中的框架有:Ruby on Rails、Grails、Django 和 CodeIgniter许可证:原始“BSD许可证” 版权所有 (c) 2015, , 保留所有权利。 如果...