创建热部署模块

参考文档 https://cwiki.apache.org/confluence/display/OFBIZ/OFBiz+Tutorial+-+A+Beginners+Development+Guide

In this part, you will learn how to create and load your own custom component and add first screen that shows “This is practice application”

1 在目录hot-deploy下创建目录practice(即为要创建的模块名称)

2 在目录hot-deploy/practice下创建文件ofbiz-component.xml

 <?xml version="1.0" encoding="UTF-8"?>
<ofbiz-component name="practice"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/ofbiz-component.xsd">
<resource-loader name="main" type="component"/>
<webapp name="practice"
title="Practice"
server="default-server"
base-permission="OFBTOOLS"
location="webapp/practice"
mount-point="/practice"
app-bar-display="false"/>
</ofbiz-component>

2.1 ofbiz-component.xml文件说明:

a. ofbiz通过ofbiz-component.xml文件识别此模块

b. 节点(resource-loader name)可以灵活设置,此处设置为main。type告诉ofbiz我们要加载一个component

 <resource-loader name="main" type="component"/>

c. 节点webapp有很多属性,通常如下:

 <webapp name="practice"
title="Practice"
server="default-server"
base-permission="OFBTOOLS"
location="webapp/practice"
mount-point="/practice"
app-bar-display="false"/>

  name :  web应用名称。

  title : 应用的标题,将被展示在顶部导航中。

  server : ofbiz通过此处值知道使用的是什么server。

  base-permission :

  location : 默认跟路径

  mount-point : 访问此服务的URL,本例中应为:localhost:8080/practice。

  app-bar-display :

3 创建 web app

3.1 创建webapp文件夹

在目录hot-deploy/practice下创建文件夹webapp,这个目录下包括模块的所有webapp相关文件。

webapp下内容遵循J2EE webapp标准。

3.2 创建practice文件夹

在目录hot-deploy/practice/webapp下创建文件夹practice(为webapp名称)。

注意:一个模块可以有多个webapp,例如marketing模块有两个webappp(marketing和sfa);

3.3 创建WEB-INF文件夹

在目录hot-deploy/practice/webapp/practice下创建WEB-INF文件夹:

一个OFBiz web application 需要放置两个配置文件(controller.xml 和 web.xml )。

a. controller.xml : 告诉OFBiz一个请求过来该如何处理,通过哪个action去处理,通过那个page去渲染。

b. web.xml : 告诉OFBiz 此web applation 可用的资源(database and business logic access),怎样去处理web相关问题,比如欢迎页面、重定向、错误页面等。

3.4 创建web.xml(web.xml遵循J2EE的webapp规格)


 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<context-param>
<param-name>webSiteId</param-name>
<param-value>PRACTICE</param-value>
<description>A unique ID used to look up the WebSite entity to get
information about catalogs, etc.</description>
</context-param>
<context-param>
<param-name>localDispatcherName</param-name>
<param-value>practice</param-value>
<description>A unique name used to identify/recognize the local
dispatcher for the Service Engine</description>
</context-param>
<context-param>
<param-name>mainDecoratorLocation</param-name>
<param-value>component://practice/widget/PracticeScreens.xml</param-value>
<!-- change the path to the following if the above doesn't work for you -->
<!-- <param-value>component://practice/webapp/practice/widget/PracticeScreens.xml</param-value> -->
<description>The location of the main-decorator screen to use for this
webapp; referred to as a context variable in screen def XML files.</description>
</context-param> <filter>
<filter-name>ContextFilter</filter-name>
<display-name>ContextFilter</display-name>
<filter-class>org.ofbiz.webapp.control.ContextFilter</filter-class>
<init-param><param-name>disableContextSecurity</param-name><param-value>N</param-value></init-param>
<init-param>
<param-name>allowedPaths</param-name>
<param-value>/error:/control:/select:/index.html:/index.jsp:/default.html:/default.jsp:/images:/includes/maincss.css</param-value>
</init-param>
<init-param>
<param-name>errorCode</param-name>
<param-value>403</param-value>
</init-param>
<init-param>
<param-name>redirectPath</param-name>
<param-value>/control/main</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>ContextFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <servlet>
<servlet-name>ControlServlet</servlet-name>
<display-name>ControlServlet</display-name>
<description>Main Control Servlet</description>
<servlet-class>org.ofbiz.webapp.control.ControlServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ControlServlet</servlet-name>
<url-pattern>/control/*</url-pattern>
</servlet-mapping> <session-config>
<session-timeout>60</session-timeout><!-- in minutes -->
</session-config> <welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
</welcome-file-list>
</web-app>

3.5 创建controller.xml

 <?xml version="1.0" encoding="UTF-8"?>
<site-conf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/site-conf.xsd">
<include location="component://common/webcommon/WEB-INF/common-controller.xml"/>
<description>Practice Component Site Configuration File</description>
<owner>Copyright 2001-2009 The Apache Software Foundation</owner>
<handler name="screen" type="view" class="org.ofbiz.widget.screen.ScreenWidgetViewHandler"/>
<!-- Request Mappings -->
<request-map uri="main">
<security https="false" auth="false"/>
<response name="success" type="view" value="main"/>
</request-map>
<!-- end of request mappings -->
<!-- View Mappings -->
<view-map name="main" type="screen" page="component://practice/widget/PracticeScreens.xml#main"/>
<!-- change the path to the following if the above doesn't work for you -->
<!-- <view-map name="main" type="screen" page="component://practice/webapp/practice/widget/PracticeScreens.xml#main"/> --> <!-- end of view mappings -->
</site-conf>

3.6 创建error文件夹

在目录hot-deploy/practice/webapp/practice下创建文件夹error,并且在此文件夹创建error.jsp

3.7 创建widget文件夹

在目录hot-deploy/practice下创建文件夹widget,并且创建PracticeScreens.xml文件

 <?xml version="1.0" encoding="UTF-8"?>
<screens xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-screen.xsd">
<screen name="main">
<section>
<widgets>
<label text="This is first practice"/>
</widgets>
</section>
</screen>
</screens>

3.8 运行

http://localhost:8080/practice/control/main

OFBiz进阶之HelloWorld(一)创建热部署模块的更多相关文章

  1. OFBiz进阶之HelloWorld(二)创建热部署模块

    参考文档 https://cwiki.apache.org/confluence/display/OFBIZ/OFBiz+Tutorial+-+A+Beginners+Development+Guid ...

  2. OFBiz进阶之HelloWorld(五)创建新实体

    参考文档 https://cwiki.apache.org/confluence/display/OFBIZ/OFBiz+Tutorial+-+A+Beginners+Development+Guid ...

  3. OFBiz进阶之HelloWorld(三)CRUD操作

    参考文档 https://cwiki.apache.org/confluence/display/OFBIZ/OFBiz+Tutorial+-+A+Beginners+Development+Guid ...

  4. Spring Boot在开发时实现热部署(开发时修改文件保存后自动重启应用)(spring-boot-devtools)

    热部署是什么 大家都知道在项目开发过程中,常常会改动页面数据或者修改数据结构,为了显示改动效果,往往需要重启应用查看改变效果,其实就是重新编译生成了新的Class文件,这个文件里记录着和代码等对应的各 ...

  5. spring boot修改代码后无需重启设置,在开发时实现热部署

    Spring Boot在开发时实现热部署(开发时修改文件保存后自动重启应用)(spring-boot-devtools) 热部署是什么 大家都知道在项目开发过程中,常常会改动页面数据或者修改数据结构, ...

  6. idea热部署

    <!-- 热部署模块 --> <dependency> <groupId>org.springframework.boot</groupId> < ...

  7. 添加spring-boot-devtools热部署报错

    使用的eclipse部署的spring boot,百度了下,大部分的问题都是说IDE工具使用热部署无法成功的解决方案,看了很懵逼 <!-- 热部署模块 --> <dependency ...

  8. Spring Boot 系列(六)web开发-Spring Boot 热部署

    Spring Boot 热部署 实际开发中,修改某个页面数据或逻辑功能都需要重启应用.这无形中降低了开发效率,所以使用热部署是十分必要的. 什么是热部署? 应用启动后会把编译好的Class文件加载的虚 ...

  9. springboot实现热部署,修改代码不用重启服务

    1.引入热部署依赖 <!-- 热部署模块 --> <dependency> <groupId>org.springframework.boot</groupI ...

随机推荐

  1. Java基础知识强化之多线程笔记02:多线程之 面试题(常问)

    1. 多线程有几种实现方案,分别是哪几种 ? 两种.   继承Thread类  实现Runnable接口 扩展一种:实现Callable接口.这个得和线程池结合. 2.  同步有几种方式,分别是什么? ...

  2. 多线程NSOperation

      NSOperation(经常使用): 1.为什么会有NSOperation?弥补gcd的一些问题:1)下载为例子:如果gcd放到队列中的block操作面对网络有问题,block之外无法取消bloc ...

  3. signal函数、sigaction函数及信号集(sigemptyset,sigaddset)操作函数

    信号是与一定的进程相联系的.也就是说,一个进程可以决定在进程中对哪些信号进行什 么样的处理.例如,一个进程可以忽略某些信号而只处理其他一些信号:另外,一个进程还可以选择如何处理信号.总之,这些总与特定 ...

  4. oracle学习总结2

    1:常用的函数 to_date()函数,将字符串转换为日期格式select to_date('2015-09-12','yyyy-MM-dd') from dual; --其中后面的日期格式要和前面要 ...

  5. Linux清空内存缓存

    > /proc/sys/vm/drop_caches

  6. 【转】Emmagee app性能测试工具使用教程

    简介 Emmagee是网易杭州研究院QA团队开发的一个简单易上手的Android性能监测小工具,主要用于监控单个App的CPU,内存,流量,启动耗时,电量,电流等性能状态的变化,且用户可自定义配置监控 ...

  7. .NET技能分析

    知乎话题:如何面试.NET/ASP.NET工程师? No.1初级:1.对 C#(推荐) 或 VB 语言直至与 .NET 4 (目前为止)相匹配的版本,绝大多数特性熟悉并使用过2.通晓 HTTP 协议的 ...

  8. JAXB - Unmarshalling

    A simple approach for unmarshalling an XML document consists of the creation of a JAXB context and t ...

  9. Service的一些使用

    service服务一般主要是作为后台服务使用的,前台服务一般结合通知一起. service一般主要用作长期后台服务的,而且和Activity结合性不那么紧密, 一般如果需要频繁的更新UI主要是用Act ...

  10. linux字符设备驱动学习笔记(一):简单的字符设备驱动

    最近在鼓捣lnux字符设备驱动,在网上搜集的各种关于linux设备驱动的代码和注释,要么是针对2.4的,要么是错误百出,根本就不能运行成功,真希望大家在发博客的时候能认真核对下代码的正确性,特别是要把 ...