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

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

10 333 0
Tài liệu đã được kiểm tra trùng lặp

Đ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

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

You can check that in the Package Explorer window as shown in the following screenshot: Configuring the build path Now you need to configure the build path so that when you create any J

Trang 1

4 The project named wcmbook will be created with a src folder and the JRE

library with the required jar files 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:

Configuring the build path

Now you need to configure the build path so that when you create any Java files, it

can automatically be compiled by Eclipse For that, make sure the Project | Build Automatically option is checked To configure 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 files from the Alfresco installed folder, tomcat/lib, and add those to this library Also select all the jar files 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.

Trang 2

Source code tree

Create the following folder structure for the project to store different types of files:

• src

° <Java classes with package>

• config

° alfresco

• extension

• <configuration files>

• messages

• <resource bundle files>

• web

° scripts

• /src: Put all your source Java classes in this folder with respective package structure

• /config/alfresco/extension: Place all your extension configuration files

in this folder

• /config/alfresco/messages: Put Resource Bundle files (properties file) in this folder

• /web/jsp: Place any custom or modified 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 modified CSS files in this folder It's a best practice to create an extension folder inside the css folder and put all the custom CSS files in that folder

• /web/images: Place any images that you have modified or newly created in this folder

• /web/scripts: Place any custom JavaScript files used by the user interface in this folder

Trang 3

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:

Trang 4

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 file in Eclipse

Creating the build.xml file:

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 file and save it You can have build targets for compiling the code, packaging the jar file, and so on The build file 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" />

Trang 5

<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>

Trang 6

<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 file, we have used some of the properties that we need to define in the build.properties file

Trang 7

Creating the build.properties file:

# 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 file, you can change the values for the properties accordingly The build.xml file will read the properties from this file

When you create the build.xml file, you can see all of the targets for the build file 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.

Trang 8

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 configuration dialog screen, choose the target that you want to run from the available list of all targets of the build file 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 file 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 configure Eclipse and start Alfresco in the debugging mode This will help

us in debugging the code for the Alfresco application The steps to configure 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 configuration.

Trang 9

4 Browse the project and enter the port number similar to the debug port in the catalina.bat (8888) file as shown in the following screenshot:

5 Start the Alfresco server

6 Put the breakpoint in the file, which you want to debug or where you want the control to stop

7 Start the debug that you have just configured

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

Trang 10

• Using a bundle that includes a preconfigured Tomcat server, the Alfresco Web Archive (WAR), batch files, database setup scripts, and a sample

extensions folder

• Using a standard WAR file 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 Configure 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 file: Alfresco-Community-3.2-Full-Setup.exe

2 Double-click on the downloaded file 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 confirm that you want to install Alfresco on your

computer, click on Yes.

5 The installation wizard launches

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

TỪ KHÓA LIÊN QUAN