Ant target for the automatic creation of an ofbiz component in the hot-deploy folder.

ant create-component

You will be prompted for:
1) component name (e.g. "test")
2) component resource name (e.g. "Test")
3) webapp name (e.g. "testapp")
4) base permission (e.g. "TEST")

and the target will create the component in the hot-deploy folder.
Restart ofbiz and the new application will be up and running.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@741605 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jacopo Cappellato
2009-02-06 16:04:05 +00:00
parent 56c6ad4660
commit 83ad2d2294
17 changed files with 456 additions and 0 deletions
+95
View File
@@ -382,4 +382,99 @@ under the License.
<arg value="test"/>
</java>
</target>
<target name="create-component"
description="Creates the layout of an OFBiz component in the hot-deploy folder.">
<input addproperty="component-name" message="Component name: "/>
<input addproperty="component-resource-name" message="Component resource name: "/>
<input addproperty="webapp-name" message="Webapp name: "/>
<input addproperty="base-permission" message="Base permission: "/>
<echo>The following hot-deploy component will be created:
Name: ${component-name}
Resource Name: ${component-resource-name}
Webapp Name: ${webapp-name}
Base permission: ${base-permission}
Folder: ${basedir}/hot-deploy/${component-name}
</echo>
<input addproperty="confirm-component-creation" message="Confirm: " defaultvalue="N" validargs="Y,N"/>
<fail message="Component creation cancelled by the user.">
<condition>
<equals arg1="${confirm-component-creation}" arg2="N"/>
</condition>
</fail>
<filterset id="replacePlaceholders">
<filter token="component-name" value="${component-name}"/>
<filter token="component-resource-name" value="${component-resource-name}"/>
<filter token="base-permission" value="${base-permission}"/>
<filter token="webapp-name" value="${webapp-name}"/>
</filterset>
<mkdir dir="${basedir}/hot-deploy/${component-name}"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/config"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/data"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/dtd"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/entitydef"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/lib"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/patches"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/script"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/servicedef"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/src"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/testdef"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/webapp"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/webapp/${webapp-name}"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/webapp/${webapp-name}/error"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/webapp/${webapp-name}/WEB-INF"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/webapp/${webapp-name}/WEB-INF/actions"/>
<mkdir dir="${basedir}/hot-deploy/${component-name}/widget/"/>
<copy file="${basedir}/framework/resources/templates/ofbiz-component.xml" tofile="${basedir}/hot-deploy/${component-name}/ofbiz-component.xml">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/build.xml" tofile="${basedir}/hot-deploy/${component-name}/build.xml">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/TypeData.xml" tofile="${basedir}/hot-deploy/${component-name}/data/${component-resource-name}TypeData.xml">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/SecurityData.xml" tofile="${basedir}/hot-deploy/${component-name}/data/${component-resource-name}SecurityData.xml">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/DemoData.xml" tofile="${basedir}/hot-deploy/${component-name}/data/${component-resource-name}DemoData.xml">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/entitymodel.xml" tofile="${basedir}/hot-deploy/${component-name}/entitydef/entitymodel.xml">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/services.xml" tofile="${basedir}/hot-deploy/${component-name}/servicedef/services.xml">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/UiLabels.xml" tofile="${basedir}/hot-deploy/${component-name}/config/${component-resource-name}UiLabels.xml">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/index.jsp" tofile="${basedir}/hot-deploy/${component-name}/webapp/${webapp-name}/index.jsp">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/error.jsp" tofile="${basedir}/hot-deploy/${component-name}/webapp/${webapp-name}/error/error.jsp">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/controller.xml" tofile="${basedir}/hot-deploy/${component-name}/webapp/${webapp-name}/WEB-INF/controller.xml">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/web.xml" tofile="${basedir}/hot-deploy/${component-name}/webapp/${webapp-name}/WEB-INF/web.xml">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/CommonScreens.xml" tofile="${basedir}/hot-deploy/${component-name}/widget/CommonScreens.xml">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/Screens.xml" tofile="${basedir}/hot-deploy/${component-name}/widget/${component-resource-name}Screens.xml">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/Menus.xml" tofile="${basedir}/hot-deploy/${component-name}/widget/${component-resource-name}Menus.xml">
<filterset refid="replacePlaceholders"/>
</copy>
<copy file="${basedir}/framework/resources/templates/Forms.xml" tofile="${basedir}/hot-deploy/${component-name}/widget/${component-resource-name}Forms.xml">
<filterset refid="replacePlaceholders"/>
</copy>
<echo>Component successfully created in folder ${basedir}/hot-deploy/${component-name}.
Restart OFBiz and then visit the URL: http://localhost:8080/${webapp-name}
</echo>
</target>
</project>
@@ -0,0 +1,49 @@
<?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-decorator">
<section>
<actions>
<property-map resource="@component-resource-name@UiLabels" map-name="uiLabelMap" global="true"/>
<property-map resource="CommonUiLabels" map-name="uiLabelMap" global="true"/>
<set field="layoutSettings.companyName" from-field="uiLabelMap.@component-resource-name@CompanyName" global="true"/>
<set field="layoutSettings.companySubtitle" from-field="uiLabelMap.@component-resource-name@CompanySubtitle" global="true"/>
<set field="activeApp" value="@webapp-name@" global="true"/>
<set field="applicationMenuName" value="MainAppBar" global="true"/>
<set field="applicationMenuLocation" value="component://@component-name@/widget/@component-resource-name@Menus.xml" global="true"/>
<set field="applicationTitle" value="${uiLabelMap.@component-resource-name@Application}" global="true"/>
</actions>
<widgets>
<include-screen name="GlobalDecorator" location="component://common/widget/CommonScreens.xml"/>
</widgets>
</section>
</screen>
<screen name="@component-resource-name@CommonDecorator">
<section>
<actions>
<set field="headerItem" value="main"/>
</actions>
<widgets>
<decorator-screen name="main-decorator" location="${parameters.mainDecoratorLocation}">
<decorator-section name="body">
<section>
<condition>
<if-has-permission permission="@base-permission@" action="_VIEW"/>
</condition>
<widgets>
<decorator-section-include name="body"/>
</widgets>
<fail-widgets>
<label style="h3">${uiLabelMap.@component-resource-name@ViewPermissionError}</label>
</fail-widgets>
</section>
</decorator-section>
</decorator-screen>
</widgets>
</section>
</screen>
</screens>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<entity-engine-xml>
</entity-engine-xml>
+5
View File
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<forms xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-form.xsd">
</forms>
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<menus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-menu.xsd">
<menu name="MainAppBar" title="${uiLabelMap.@component-resource-name@Application}" extends="CommonAppBarMenu" extends-resource="component://common/widget/CommonMenus.xml">
<menu-item name="main" title="${uiLabelMap.CommonMain}"><link target="main"/></menu-item>
</menu>
</menus>
+18
View File
@@ -0,0 +1,18 @@
<?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>
<actions>
</actions>
<widgets>
<decorator-screen name="@component-resource-name@CommonDecorator" location="component://@component-name@/widget/CommonScreens.xml">
<decorator-section name="body">
</decorator-section>
</decorator-screen>
</widgets>
</section>
</screen>
</screens>
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<entity-engine-xml>
<SecurityPermission description="View operations in the @component-resource-name@ Component." permissionId="@base-permission@_VIEW"/>
<SecurityPermission description="Create operations in the @component-resource-name@ Component." permissionId="@base-permission@_CREATE"/>
<SecurityPermission description="Update operations in the @component-resource-name@ Component." permissionId="@base-permission@_UPDATE"/>
<SecurityPermission description="Delete operations in the @component-resource-name@ Component." permissionId="@base-permission@_DELETE"/>
<SecurityPermission description="ALL operations in the @component-resource-name@ Component." permissionId="@base-permission@_ADMIN"/>
<SecurityGroupPermission groupId="FULLADMIN" permissionId="@base-permission@_ADMIN"/>
<SecurityGroupPermission groupId="FLEXADMIN" permissionId="@base-permission@_CREATE"/>
<SecurityGroupPermission groupId="FLEXADMIN" permissionId="@base-permission@_DELETE"/>
<SecurityGroupPermission groupId="FLEXADMIN" permissionId="@base-permission@_UPDATE"/>
<SecurityGroupPermission groupId="FLEXADMIN" permissionId="@base-permission@_VIEW"/>
<SecurityGroupPermission groupId="VIEWADMIN" permissionId="@base-permission@_VIEW"/>
<SecurityGroupPermission groupId="BIZADMIN" permissionId="@base-permission@_ADMIN"/>
</entity-engine-xml>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<entity-engine-xml>
</entity-engine-xml>
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<property key="@component-resource-name@Application">
<value xml:lang="en">@component-resource-name@ Application</value>
</property>
<property key="@component-resource-name@CompanyName">
<value xml:lang="en">OFBiz: @component-resource-name@</value>
</property>
<property key="@component-resource-name@CompanySubtitle">
<value xml:lang="en">Part of the Open For Business Family of Open Source Software</value>
</property>
<property key="@component-resource-name@ViewPermissionError">
<value xml:lang="en">You are not allowed to view this page.</value>
</property>
</resource>
+55
View File
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="OFBiz - @component-resource-name@ Component" default="jar" basedir=".">
<import file="../../common.xml"/>
<!-- ================================================================== -->
<!-- Initialization of all property settings -->
<!-- ================================================================== -->
<property environment="env"/>
<property name="desc" value="@component-resource-name@ Component"/>
<property name="name" value="ofbiz-@component-name@"/>
<property name="ofbiz.home.dir" value="../.."/>
<property name="src.dir" value="src"/>
<property name="dtd.dir" value="dtd"/>
<property name="lib.dir" value="lib"/>
<property name="build.dir" value="build"/>
<path id="local.class.path">
<fileset dir="${lib.dir}" includes="*.jar"/>
<fileset dir="../../framework/base/lib" includes="*.jar"/>
<fileset dir="../../framework/base/lib/j2eespecs" includes="*.jar"/>
<fileset dir="../../framework/base/build/lib" includes="*.jar"/>
<fileset dir="../../framework/entity/lib" includes="*.jar"/>
<fileset dir="../../framework/entity/build/lib" includes="*.jar"/>
<fileset dir="../../framework/security/build/lib" includes="*.jar"/>
<fileset dir="../../framework/service/lib" includes="*.jar"/>
<fileset dir="../../framework/service/build/lib" includes="*.jar"/>
<fileset dir="../../framework/minilang/build/lib" includes="*.jar"/>
<fileset dir="../../framework/widget/build/lib" includes="*.jar"/>
<fileset dir="../../framework/webapp/lib" includes="*.jar"/>
<fileset dir="../../framework/webapp/build/lib" includes="*.jar"/>
</path>
<!-- ================================================================== -->
<!-- Compilation of the source files -->
<!-- ================================================================== -->
<target name="classes" depends="prepare">
<javac15/>
</target>
<!-- ================================================================== -->
<!-- Build JavaDoc -->
<!-- ================================================================== -->
<target name="docs" depends="prepare-docs">
<javadoc packagenames="org.ofbiz.@component-name@.*"
classpathref="local.class.path"
destdir="${build.dir}/javadocs"
Windowtitle="Open for Business - ${desc}">
<sourcepath path="${src.dir}"/>
</javadoc>
</target>
</project>
@@ -0,0 +1,31 @@
<?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">
<!-- The controller elements that are common to all OFBiz components
can be found in the following xml file. A component can override the
elements found in the common-controller.xml file. -->
<include location="component://common/webcommon/WEB-INF/common-controller.xml"/>
<description>@component-resource-name@ Component Site Configuration File</description>
<owner></owner>
<!-- Events to run on every request before security (chains exempt) -->
<!--
<preprocessor>
</preprocessor>
-->
<!-- Events to run on every request after all other processing (chains exempt) -->
<!--
<postprocessor>
<event type="java" path="org.ofbiz.webapp.event.TestEvent" invoke="test"/>
</postprocessor>
-->
<!-- Request Mappings -->
<request-map uri="main"><security https="true" auth="true"/><response name="success" type="view" value="main"/></request-map>
<request-map uri="authview"><security https="true" auth="true"/><response name="success" type="view" value="main"/></request-map>
<!-- View Mappings -->
<view-map name="main" type="screen" page="component://@component-name@/widget/@component-resource-name@Screens.xml#main"/>
</site-conf>
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<entitymodel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/entitymodel.xsd">
<!-- ========================================================= -->
<!-- ======================== Defaults ======================= -->
<!-- ========================================================= -->
<title>Entity of @component-resource-name@ Component</title>
<description>None</description>
<copyright></copyright>
<author>None</author>
<version></version>
</entitymodel>
+34
View File
@@ -0,0 +1,34 @@
<%@ page import="org.ofbiz.base.util.*" %>
<html>
<head>
<title>Open For Business Message</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<% String errorMsg = (String) request.getAttribute("_ERROR_MESSAGE_"); %>
<body bgcolor="#FFFFFF">
<div align="center">
<br/>
<table width="100%" border="1" height="200">
<tr>
<td>
<table width="100%" border="0" height="200">
<tr bgcolor="#CC6666">
<td height="45">
<div align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="4" color="#FFFFFF"><b>:ERROR MESSAGE:</b></font></div>
</td>
</tr>
<tr>
<td>
<div align="left"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><%=UtilFormatOut.replaceString(errorMsg, "\n", "<br/>")%></font></div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<div align="center"></div>
</body>
</html>
+1
View File
@@ -0,0 +1 @@
<%response.sendRedirect("control/main");%>
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<ofbiz-component name="@component-name@"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/ofbiz-component.xsd">
<!-- define resource loaders; most common is to use the component resource loader -->
<resource-loader name="main" type="component"/>
<!-- place the config directory on the classpath to access configuration files -->
<classpath type="dir" location="config"/>
<classpath type="dir" location="dtd"/>
<!-- load single or multiple external libraries -->
<classpath type="jar" location="build/lib/*"/>
<!-- entity resources: model(s), eca(s), group, and data definitions -->
<entity-resource type="model" reader-name="main" loader="main" location="entitydef/entitymodel.xml"/>
<!-- <entity-resource type="eca" reader-name="main" loader="main" location="entitydef/eecas.xml"/> -->
<entity-resource type="data" reader-name="seed" loader="main" location="data/@component-resource-name@TypeData.xml"/>
<entity-resource type="data" reader-name="seed" loader="main" location="data/@component-resource-name@SecurityData.xml"/>
<entity-resource type="data" reader-name="demo" loader="main" location="data/@component-resource-name@DemoData.xml"/>
<!-- service resources: model(s), eca(s) and group definitions -->
<service-resource type="model" loader="main" location="servicedef/services.xml"/>
<!--
<service-resource type="eca" loader="main" location="servicedef/secas.xml"/>
<service-resource type="group" loader="main" location="servicedef/groups.xml"/>
-->
<test-suite loader="main" location="testdef/tests.xml"/>
<!-- web applications; will be mounted when using the embedded container -->
<webapp name="@webapp-name@"
title="@component-resource-name@"
server="default-server"
location="webapp/@webapp-name@"
base-permission="OFBTOOLS,@base-permission@"
mount-point="/@webapp-name@"/>
</ofbiz-component>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/services.xsd">
<description>@component-resource-name@ Services</description>
<vendor></vendor>
<version>1.0</version>
</services>
+65
View File
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<display-name>Open For Business - @component-resource-name@ Component</display-name>
<description>@component-resource-name@ Component of the Open For Business Project</description>
<context-param>
<param-name>localDispatcherName</param-name><param-value>example</param-value>
<description>A unique name used to identify/recognize the local dispatcher for the Service Engine</description>
</context-param>
<context-param>
<param-name>entityDelegatorName</param-name><param-value>default</param-value>
<description>The Name of the Entity Delegator to use, defined in entityengine.xml</description>
</context-param>
<context-param>
<param-name>mainDecoratorLocation</param-name>
<param-value>component://@component-name@/widget/CommonScreens.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>
<context-param>
<param-name>widgetVerbose</param-name>
<param-value>false</param-value>
<description>Enable widget boundary comments. See org.ofbiz.widget.ModelWidget.widgetBoundaryCommentsEnabled().</description>
</context-param>
<context-param>
<param-name>compressHTML</param-name>
<param-value>false</param-value>
<description>Remove unnecessary whitespace from HTML output.</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>/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>
<listener><listener-class>org.ofbiz.webapp.control.ControlEventListener</listener-class></listener>
<listener><listener-class>org.ofbiz.webapp.control.LoginEventListener</listener-class></listener>
<!-- NOTE: not all app servers support mounting implementations of the HttpSessionActivationListener interface -->
<!-- <listener><listener-class>org.ofbiz.webapp.control.ControlActivationEventListener</listener-class></listener> -->
<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>