1. Trang chủ
  2. » Công Nghệ Thông Tin

Quản lý cấu hình web - part 6 pptx

10 330 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 10
Dung lượng 6,07 MB

Nội dung

Installation and Conguration [ 32 ] 4. The project named wcmbook will be created with a src folder and the JRE library with the required .jar les attached for this project (if JDK is already installed on your machine). You can check that in the Package Explorer window as shown in the following screenshot: Conguring the build path Now you need to congure the build path so that when you create any Java les, it can automatically be compiled by Eclipse. For that, make sure the Project | Build Automatically option is checked. To congure the build path for the project, follow these steps: 1. Right-click on project name, that is, wcmbook and select Build Path | Add Libraries. 2. Select User Library and click on Next. 3. Click on the User Libraries button. In the User Libraries screen, click on the New button. 4. Provide the name of the library as alfresco_lib and click on OK. 5. Select that library name and click on Add JARs. Select all the .jar les from the Alfresco installed folder, tomcat/lib, and add those to this library. Also select all the .jar les from the tomcat/webapps/alfresco/WEB-INF/lib folder and add those to this library. Once done, click on OK. 6. Then click on Finish. Download from Wow! eBook <www.wowebook.com> Chapter 2 [ 33 ] Source code tree Create the following folder structure for the project to store different types of les: • src ° <Java classes with package> • cong ° alfresco • extension • <conguration les> • messages • <resource bundle les> • web ° jsp ° css ° scripts ° images ° … • /src: Put all your source Java classes in this folder with respective package structure. • /config/alfresco/extension: Place all your extension conguration les in this folder. • /config/alfresco/messages: Put Resource Bundle les (properties le) in this folder. • /web/jsp: Place any custom or modied JSPs in this folder. It's a best practice to create an extension folder inside the jsp folder and put all the custom JSPs in that folder. • /web/css: Place any custom or modied CSS les in this folder. It's a best practice to create an extension folder inside the css folder and put all the custom CSS les in that folder. • /web/images: Place any images that you have modied or newly created in this folder. • /web/scripts: Place any custom JavaScript les used by the user interface in this folder. Download from Wow! eBook <www.wowebook.com> Installation and Conguration [ 34 ] To create a folder in the Eclipse project: 1. Select the web project for root-level folder or select the parent-level folder and right-click, then click on New | Folder. 2. Provide the folder name and click on Finish. To create a package in the eclipse project: 1. Select the source folder src, right-click, select New | Package. 2. In Name, provide the name of package, that is, com.Cignex.web.bean, and so on. Once you are done with the package and folder structure creation, it will look similar to the following screenshot: Download from Wow! eBook <www.wowebook.com> Chapter 2 [ 35 ] Build process We will use Apache Ant, which is a Java-based build tool, for building the application from Eclipse. Why to use a build tool There are a number of steps required to transform the source into a deployable software solution. In general, a build tool allows developers and build managers to describe the build process. In a build, some steps may need to be executed before others or they may be independent of others. In summary, a build tool provides a mechanism to describe the operations and structure of the build process to deploy the code. Integrating Ant with Eclipse As we are using Eclipse as our development environment, we will learn how we can integrate Ant with Eclipse for the build process. First we need to create a new build le in Eclipse. Creating the build.xml le: 1. Right-click on project name wcmbook in Package Explorer 2. Select New | File 3. In the File Name box, type build.xml 4. Click on Finish Enter the targets for Ant Build in this le and save it. You can have build targets for compiling the code, packaging the .jar le, and so on. The build le we will use for our examples throughout the book will look like: <project name="Cignex AMP Build File" default="package-jar" basedir="."> <property file="build.properties" /> <target name="clean" description="Cleans Build directory"> <delete dir="${build.dir}" /> <delete dir="${project.dir}/lib" /> </target> <target name="clean-alfresco" description="Cleans alfresco directory"> <delete dir="${alfresco.work.home}/tomcat/webapps/alfresco" /> </target> Download from Wow! eBook <www.wowebook.com> Installation and Conguration [ 36 ] <target name="mkdirs" description="Creates Build directory"> <mkdir dir="${build.dir}/dist" /> <mkdir dir="${project.dir}/lib" /> </target> <path id="class.path"> <fileset dir="${alfresco.work.home}/tomcat/lib" includes="*.jar"/> <dirset dir="${alfresco.work.home}/tomcat/webapps/alfresco/ WEB-INF/classes" /> <fileset dir="${alfresco.work.home}/tomcat/webapps/alfresco/ WEB-INF/lib" includes="*.jar" excludes="cignex.jar" /> </path> <target name="compile" depends="clean,mkdirs" description="cmopiles the java source code"> <mkdir dir="${build.dir}/classes" /> <javac classpathref="class.path" srcdir="${project.dir}/src" destdir="${build.dir}/classes" debug="true"/> </target> <target name="package-jar" depends="compile" description="Package the classes into jar file"> <jar destfile="${project.dir}/lib/${package.file}"> <fileset dir="${build.dir}/classes" includes="**/*.class" /> </jar> </target> <target name="package-amp" depends="package-jar" description="Package the Module"> <zip destfile="${amp.file}" update="true"> <fileset dir="${project.dir}" includes="web/**/*.*" /> <fileset dir="${project.dir}" includes="config/**/*.*" /> <fileset dir="${project.dir}" includes="lib**/*.jar" /> <fileset dir="${project.dir}" includes="ext-lib**/*.jar" /> <fileset dir="${project.dir}" includes="module.properties" /> <fileset dir="${project.dir}" includes="file-mapping.properties" /> </zip> </target> <target name="update-war" depends="package-amp,clean-alfresco" description="Update the WAR file."> <echo>Installing Cignex AMP into WAR</echo> Download from Wow! eBook <www.wowebook.com> Chapter 2 [ 37 ] <java dir="." fork="true" classname="org.alfresco.repo.module. tool.ModuleManagementTool"> <classpath refid="class.path" /> <arg line="install ${amp.file} ${alfresco.war.file} -verbose" /> </java> </target> <target name="package-extension" description="Package the extension files into zip file" depends="package-jar"> <zip destfile="${package.file.zip}"> <zipfileset file="${project.dir}/lib/*.jar" prefix="WEB-INF/lib" /> <zipfileset dir="${web.dir}" /> <zipfileset dir="${alfresco.dir}" prefix="WEB-INF/classes/alfresco"/> </zip> </target> <target name="war-backup" description="Package the extension files into zip file" depends="package-extension"> <copy file="${alfresco.war.file}" tofile="${alfresco.war.backup}"/> </target> <target name="integrate-extension" description="Integrate the extension files to existing alfresco.war file" depends="war-backup,clean-alfresco"> <available file="${alfresco.war.file}" type="file" property="alfresco.war.present" /> <fail unless="alfresco.war.present" message="Could not find alfresco.war, please provide the correct path" /> <zip destfile="${alfresco.war.file}" update="true"> <zipfileset file="${package.file.jar}" prefix="WEB-INF/lib" /> <zipfileset dir="${web.dir}" /> <zipfileset dir="${alfresco.dir}" prefix="WEB-INF/classes/alfresco"/> </zip> </target> </project> Here in this build le, we have used some of the properties that we need to dene in the build.properties le. Download from Wow! eBook <www.wowebook.com> Installation and Conguration [ 38 ] Creating the build.properties le: # Property file for ant Build project.dir=. build.dir=${project.dir}/build package.file=cignex.jar package.file.zip=${build.dir}/dist/cignex.zip amp.file=${build.dir}/dist/cignex-install.amp web.dir=${project.dir}/web alfresco.dir=${project.dir}/config/alfresco alfresco.work.home=C:/alfresco_3.2r alfresco.war.file=${alfresco.work.home}/tomcat/webapps/alfresco.war alfresco.war.backup=${alfresco.war.file}.backup_ In this le, you can change the values for the properties accordingly. The build.xml le will read the properties from this le. When you create the build.xml le, you can see all of the targets for the build le in the Outline view at the right-hand side in Eclipse. Running the Ant target: There are three different ways to run a particular build target. 1st Approach: 1. Right-click on build.xml in the Package Explorer. Download from Wow! eBook <www.wowebook.com> Chapter 2 [ 39 ] 2. Select Run | Ant Build. This will run the default target for the Ant Build and gives you the results in Eclipse's Console view. 2nd Approach: 1. Right-click on build.xml in the Package Explorer. 2. Select Run | Ant Build with ellipsis (three dots). 3. From the Ant launch conguration dialog screen, choose the target that you want to run from the available list of all targets of the build le and click on Run. 3rd Approach: 1. Go to Windows | Show View | Ant (if Ant is not available there, click on Other… and select Ant | Ant from there). 2. You will see the Ant view at the right-hand side in Eclipse. 3. Drag the build.xml le from Package Explorer to this Ant view. 4. Double-click on the target you want to run from the Ant view. Debugging the Alfresco application in an Eclipse environment We can congure Eclipse and start Alfresco in the debugging mode. This will help us in debugging the code for the Alfresco application. The steps to congure this are as follows: 1. Modify catalina.bat available at <alfresco_home>\tomcat\bin to add the following line for DEBUG_OPTS=: set DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,susp end=n,address=8888 2. Now in Eclipse, navigate to Windows | Open perspective | Other | Debug, which will open the debug perspective. 3. Click on Run | Open Debug Dialog | Remote Java Application | New conguration. Download from Wow! eBook <www.wowebook.com> Installation and Conguration [ 40 ] 4. Browse the project and enter the port number similar to the debug port in the catalina.bat (8888) le as shown in the following screenshot: 5. Start the Alfresco server. 6. Put the breakpoint in the le, which you want to debug or where you want the control to stop. 7. Start the debug that you have just congured. 8. Use Alfresco (Web-Client) to get to the debug mode. Installing Alfresco This chapter provides information for installing Alfresco and its components. Depending on your system, you can install Alfresco using a number of different methods. For example, you can install Alfresco by: • Using an installation wizard, which contains the required software and components you need Download from Wow! eBook <www.wowebook.com> Chapter 2 [ 41 ] • Using a bundle that includes a precongured Tomcat server, the Alfresco Web Archive (WAR), batch les, database setup scripts, and a sample extensions folder • Using a standard WAR le to deploy on your existing application server A typical manual installation scenario includes the following procedure: 1. Install a Java SE Development Kit (JDK). 2. Install a supported database. 3. Install Alfresco. 4. Congure an Alfresco database. 5. Install Alfresco components. 6. Run Alfresco. Installing Alfresco on Windows This section describes how to install Alfresco using the following methods: • Complete installation • Installation excluding JDK • Tomcat bundle installation Installing Alfresco on Windows (full installation) The installation wizard for Microsoft Windows installs all of the software and components that you require for running Alfresco. 1. Browse to the Alfresco Community Edition downloads area and download the following le: Alfresco-Community-3.2-Full-Setup.exe. 2. Double-click on the downloaded le. You may see an Open File - Security Warning message, prompting you to verify that you wish to run this software. To run the installation wizard, click on Run. 3. At the Language Selection prompt, select English and click on OK. 4. When prompted to conrm that you want to install Alfresco on your computer, click on Yes. 5. The installation wizard launches. Download from Wow! eBook <www.wowebook.com> . dir="${alfresco.work.home}/tomcat/webapps/alfresco/ WEB- INF/classes" /> <fileset dir="${alfresco.work.home}/tomcat/webapps/alfresco/ WEB- INF/lib" includes="*.jar". downloads area and download the following le: Alfresco-Community-3.2-Full-Setup.exe. 2. Double-click on the downloaded le. You may see an Open File - Security Warning message, prompting you to verify. les from the tomcat/webapps/alfresco /WEB- INF/lib folder and add those to this library. Once done, click on OK. 6. Then click on Finish. Download from Wow! eBook <www.wowebook.com> Chapter

Ngày đăng: 05/07/2014, 20:21

TỪ KHÓA LIÊN QUAN