![]() ![]() ![]() ![]() ![]() ![]() |
WARNING: | This document is deprecated as of version 10.0 of WebLogic Server. This deprecation warning applies only to this documentation, and not to the underlying functionality it describes nor to the open-source Beehive project. Users who wish to develop and deploy Beehive applications should do so using Workshop for WebLogic, which offers support for all aspects of Beehive technology. Current documentation for integrating Beehive and WebLogic Server can be found at Workshop for WebLogic Platform User's Guide. |
The following sections provide information on how to create and deploy a Beehive application on WebLogic Server
Note: | If this is your second time going through the tutorial, be aware that if you change the location of the application source files you will not be able to deploy to the same server domain. To avoid this problem either (1) create a new server domain from scratch (= the first step of the tutorial) or, if you want to skip this step, (2) undeploy the application from the server first. To undeploy, run the undeploy Ant target. |
In this step you will create a new server domain that can support Beehive applications.
On the second page, place a check in the Apache Beehive checkbox before clicking the Next button.
On the third page, in the User password and Confirm user password fields, enter weblogic
.
At the conclusion of the wizard, a domain named base_domain is created at <BEA_HOME>
\user_projects\domains\base_domain
.
<BEA_HOME>\user_projects\domains\base_domain\startWebLogic.cmd
<BEA_HOME>/user_projects/domains/base_domain/startWebLogic.sh
<BEA_HOME>\user_projects\domains\base_domain\bin\setDomainEnv.cmd
<BEA_HOME>/user_projects/domains/base_domain/bin/setDomainEnv.sh
In this step you will create the basic directory structure, and build configuration files for your application.
beehive_tutorial
src
APP-INF
lib
classes
META-INF
beehive_tutorial\src
directory, create an Ant build file named build.xml
and enter the following text in it. Note that the properties user/password have the values weblogic/weblogic; these values are designed to match the Beehive-enabled server domain created in Create a Beehive-enabled Server Domain.<?xml version="1.0" encoding="UTF-8" ?>
<project default="build" basedir=".">
<property environment="env"/>
<!-- provide overrides -->
<property file="build.properties"/>
<property name="src.dir" value="${basedir}"/>
<property name="dest.dir" value="${basedir}/../build"/>
<property name="dist.dir" value="${basedir}/../dist"/>
<property name="app.name" value="beehive_tutorial"/>
<property name="ear.path" value="${dist.dir}/${app.name}.ear"/>
<property name="tmp.dir" value="${java.io.tmpdir}"/>
<property name="weblogic.home" value="${env.WL_HOME}"/>
<property name="user" value="weblogic"/>
<property name="password" value="weblogic"/>
<fail unless="weblogic.home" message="WL_HOME not set in environment"/>
<property name="beehive.home" value="${weblogic.home}/beehive"/>
<!-- beehive-imports defines dependency paths that are required by beehive-tools.xml -->
<import file="${beehive.home}/weblogic-beehive/ant/weblogic-beehive-imports.xml"/>
<!-- defines macros for build-schemas, build-controls, build-pageflows -->
<import file="${beehive.home}/weblogic-beehive/ant/weblogic-beehive-tools.xml"/>
<!-- defines macros for build-webapp -->
<import file="${beehive.home}/weblogic-beehive/ant/weblogic-beehive-buildmodules.xml"/>
<taskdef name="libclasspath" classname="weblogic.ant.taskdefs.build.LibClasspathTask"/>
<!-- Builds classpath based on the libraries defined in weblogic-application.xml. -->
<target name="init.app.libs">
<libclasspath basedir="${src.dir}" tmpdir="${tmp.dir}" property="app.lib.classpath">
<librarydir dir="${weblogic.home}/common/deployable-libraries/" />
</libclasspath>
<echo message="app.lib.claspath is ${app.lib.classpath}" level="info"/>
</target>
<target name="init.dirs">
<mkdir dir="${dest.dir}/APP-INF/classes"/>
<mkdir dir="${dest.dir}/APP-INF/lib"/>
<mkdir dir="${dist.dir}"/>
</target>
<target name="init" depends="init.app.libs,init.dirs">
<path id="app.classpath">
<pathelement location="${src.dir}/APP-INF/classes"/>
<pathelement location="${dest.dir}/APP-INF/classes"/>
<pathelement path="${app.lib.classpath}"/>
<fileset dir="${src.dir}/APP-INF/lib">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${dest.dir}/APP-INF/lib">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${beehive.home}/apache-beehive-svn-snapshot
/lib/netui">
<include name="**/*.jar"/>
<exclude name="**/beehive-netui-compiler.jar"/>
</fileset>
</path>
</target>
<target name="build" depends="compile,appc"/>
<target name="compile" depends="init"/>
<target name="clean" depends="init.dirs,clean.dest,clean.dist"/>
<target name="clean.dest">
<echo message="deleting dest.dir:${dest.dir}"/>
<delete includeemptydirs="true" >
<fileset dir="${dest.dir}" excludes=".beabuild.txt" includes="**/*" />
</delete>
</target>
<target name="clean.dist">
<echo message="deleting dist.dir:${dist.dir}"/>
<delete includeemptydirs="true" >
<fileset dir="${dist.dir}" includes="**/*" />
</delete>
</target>
<target name="appc" depends="init" >
<wlappc source="${dest.dir}" librarydir="${weblogic.home}/common/deployable-libraries/"/>
</target>
<target name="pkg.exploded">
<antcall target="clean.dist"></antcall>
<wlpackage toDir="${dist.dir}" srcdir="${src.dir}" destdir="${dest.dir}" />
</target>
<target name="deploy.exploded" >
<wldeploy user="${user}" password="${password}" action="deploy" name="${app.name}" source="${dist.dir}"/>
</target>
<target name="deploy" >
<wldeploy user="${user}" password="${password}" action="deploy" name="${app.name}" source="${dest.dir}"/>
</target>
<target name="redeploy">
<wldeploy user="${user}" password="${password}" action="redeploy" name="${app.name}"/>
</target>
<!-- This target is useful if you want to move the location of the
tutorial source files. Undeploy the app from the server, move the
source files, and then deploy the app again to the server.-->
<target name="undeploy">
<wldeploy user="${user}" password="${password}" action="undeploy" name="${app.name}"/>
</target>
</project>
beehive_tutorial\src\META-INF
directory, create a configuration file named application.xml
and enter the following text in it.<application xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.4">
<display-name>beehive_tutorial</display-name>
</application>
beehive_tutorial\src\META-INF
directory, create a configuration file named weblogic-application.xml
and enter the following text in it. This configuration file informs WebLogic Server that your application uses Beehive functionality, so that the appropriate libraries, in the form of JAR files, are made available at build-time and run-time.<weblogic-application xmlns="http://www.bea.com/ns/weblogic/90">
<library-ref>
<library-name>weblogic-controls-1.0</library-name>
</library-ref>
<library-ref>
<library-name>beehive-controls-1.0</library-name>
</library-ref>
</weblogic-application>
In this step you will create a page flow web application. Page flows form the user interface for Beehive applications, allowing users to interact with your application through JSPs.
<BEA_HOME>
\wlserver_10.0\beehive\apache-beehive-svn-snapshot
\samples\netui-blank
netui-blank
is a template web application.
netui-blank
to myWebApp
. Before proceeding, ensure that the following directory structure exists:beehive_tutorialsrc
myWebApp
srcweb
Controller.java
index.jsp
resources
WEB-INF
beehive_tutorial\src\META-INF\application.xml
so it appears as follows. Code to add is shown in bold.<application xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.4">
<display-name>beehive_tutorial</display-name><module>
</application>
<web>
<web-uri>myWebApp</web-uri>
<context-root>/myWebApp</context-root>
</web>
</module>
beehive_tutorial\src\myWebApp\web\index.jsp
so it appears as follows. Code to edit appears in bold.<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="http://beehive.apache.org/netui/tags-databinding-1.0" prefix="netui-data"%>
<%@ taglib uri="http://beehive.apache.org/netui/tags-html-1.0" prefix="netui"%>
<%@ taglib uri="http://beehive.apache.org/netui/tags-template-1.0" prefix="netui-template"%>
<netui:html>
<head>
<title>Beehive Tutorial Test Page
</title>
<netui:base/>
</head>
<netui:body>
<h3>
<p>
Beehive Tutorial Test Page
</h3>Welcome to the Beehive Tutorial!
</p>
</netui:body>
</netui:html>
beehive_tutorial\src\myWebApp\web\WEB-INF
, create a configuration named weblogic.xml
and enter the following text in it.<weblogic-web-app
xmlns="http://www.bea.com/ns/weblogic/90"
xmlns:j2ee="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.bea.com/ns/weblogic/90
http://www.bea.com/ns/weblogic/90/weblogic-web-app.xsd">
<library-ref>
<library-name>beehive-netui-1.0</library-name>
</library-ref>
<library-ref>
<library-name>struts-1.1</library-name>
</library-ref>
<library-ref>
<library-name>jstl-1.1</library-name>
</library-ref>
</weblogic-web-app>
beehive_tutorial\src\build.xml
so it appears as follows. Code to add appears in bold.
<?xml version="1.0" encoding="UTF-8" ?>
<project default="build" basedir=".">
...
<target name="compile" depends="init,compile.myWebApp
"/>
. . .
<target name="redeploy">
<wldeploy user="${user}" password="${password}" action="redeploy" name="${app.name}"/>
</target>
<target name="compile.myWebApp" depends="init" >
<libclasspath basedir="${src.dir}/myWebApp" tmpdir="${tmp.dir}" property="myWebApp.lib.classpath">
<librarydir dir="${weblogic.home}/common/deployable-libraries/" />
</libclasspath>
<path id="myWebApp.build.classpath">
<path refid="app.classpath"/>
<path path="${myWebApp.lib.classpath}"/>
</path>
<copy todir="${src.dir}/myWebApp/">
<fileset dir="${src.dir}/myWebApp/web/">
<exclude name="**/*.java"/>
</fileset>
</copy>
<copy todir="${dest.dir}/WEB-INF/classes">
<fileset dir="${src.dir}/myWebApp/src/">
<include name="sql/**"/>
<include name="**/*.properties"/>
<include name="**/*.xml"/>
</fileset>
</copy>
<copy todir="${src.dir}/myWebApp/WEB-INF/src">
<fileset dir="${src.dir}/myWebApp/src/">
<exclude name="**/*.java"/>
</fileset>
</copy>
<build-webapp
webapp.src.dir="${src.dir}/myWebApp"
webapp.build.dir="${dest.dir}/myWebApp"
app.build.classpath="myWebApp.build.classpath"/>
</target>
</project>
beehive_tutorial\src\
. (Make sure you use the same command window where you ran setDomainEnv.cmd
or setDomainEnv.sh
.) ant clean build pkg.exploded
ant deploy.exploded
http://localhost:7001/myWebApp/begin.do
You should see the index.jsp
page:
Welcome to the Beehive Tutorial!
A Beehive Java Control allow you to encapsulate functionality in your applications. Typically Java Controls are used to perform the following functions:
Beehive ships with a number of “system controls,” that is, controls that are designed with some particular functionality in mind: these system controls include database, JMS, EJB, and Web Service controls.
In the following step you will add a custom control with a very simple function: it returns the message “Hello, World!”
Inside the directory beehive_tutorial\src\
, create a directory named controls
.
beehive_tutorial\src\controls
, create a directory named pkg
.Before proceeding, confirm that the following directory structure exists:
beehive_tutorial
src
controls
pkg
beehive_tutorial\src\controls\pkg\
, create a file named HelloWorld.java
. Edit HelloWorld.java
so it appears as follows:package pkg;
import org.apache.beehive.controls.api.bean.*;
@ControlInterface
public interface HelloWorld
{
String hello();
}
beehive_tutorial\src\controls\pkg\
, create a file named HelloWorldImpl.java
. Edit HelloWorldImpl.java
so it appears as follows:package pkg;
import org.apache.beehive.controls.api.bean.*;
@ControlImplementation(isTransient=true)
public class HelloWorldImpl implements HelloWorld
{
public String hello()
{
return "hello!";
}
}
beehive_tutorial\src\myWebApp\web\Controller.java
so it appears as follows. Code to add and edit appears in bold.import javax.servlet.http.HttpSession;
import org.apache.beehive.netui.pageflow.Forward;
import org.apache.beehive.netui.pageflow.PageFlowController;
import org.apache.beehive.netui.pageflow.annotations.Jpf;
import org.apache.beehive.controls.api.bean.Control;
import pkg.HelloWorld;
@Jpf.Controller(
simpleActions={
@Jpf.SimpleAction(name="begin_old
", path="index.jsp")
},
sharedFlowRefs={
@Jpf.SharedFlowRef(name="shared", type=shared.SharedFlow.class)
}
)
public class Controller
extends PageFlowController
{@Jpf.SharedFlowField(name="shared")
private shared.SharedFlow sharedFlow;
@Control
private HelloWorld _helloControl;
@Jpf.Action(
forwards={
@Jpf.Forward(name="success", path="index.jsp")
}
)
protected Forward begin() throws Exception
{
Forward f = new Forward("success");
f.addActionOutput("helloMessage", _helloControl.hello());
return f;
}
/**
* Callback that is invoked when this controller instance is created.
*/
protected void onCreate()
{
}
/**
* Callback that is invoked when this controller instance is
destroyed.
*/
protected void onDestroy(HttpSession session)
{
}
}
beehive_tutorial\src\myWebApp\web\index.jsp
so it appears as follows.<netui:html>
<head>
<title>Beehive Tutorial Test Page</title>
<netui:base/>
</head>
<netui:body>
<h3>
Beehive Tutorial Test Page
</h3>
<p>
Welcome to the Beehive Tutorial!
</p><p>
</netui:body>
Response from the hello() method on the HelloWorld Control:
<netui:span style="color:#FF0000" value="${pageInput.helloMessage}"/>
</p>
</netui:html>
beehive_tutorial\src\build.xml
so it appears as follows. Code to add appears in bold.. . .
<target name="compile" depends="init,compile.helloWorldControl,
compile.myWebApp"/>
. . .
<target name="compile.helloWorldControl" depends="init">
<build-controls
srcdir="${src.dir}"
destDir="${dest.dir}/APP-INF/classes"
tempdir="${tmp.dir}/${app.name}/controls/build-controls"
classpathRef="app.classpath"
/>
<!-- clean up duplicate myWebApp <apt> output -->
<delete>
<fileset dir="${dest.dir}/APP-INF/classes" excludes="pkg/**/*.class"/>
</delete>
</target>
</project>
setDomainEnv.cmd
or setDomainEnv.sh
.Note: | In the following build process, you will see some build warnings. These warnings are harmless and do not affect the final product of compilation. |
ant clean build pkg.exploded
ant deploy.exploded
http://localhost:7001/myWebApp/begin.do
You should see the following JSP page.
Beehive Tutorial Test Page
Welcome to the Beehive Tutorial!
Response from the hello() method on the HelloWorld Control: hello!
Web services provide an XML-based interface for your application. In this step you will create an XML-based way to communicate with your application.
beehive_tutorial\src\
create a folder named services
.beehive_tutorial\src\services\
create a folder named pkg
.beehive_tutorial\src\services\pkg\
create a file named HelloWorldService.java
.HelloWorldService.java
so it appears as follows:package pkg;
import javax.jws.*;
import org.apache.beehive.controls.api.bean.Control;
import pkg.HelloWorld;
@WebService
public class HelloWorldService
{
@Control
private HelloWorld _helloControl;
@WebMethod()
public String hello()
{
String message = _helloControl.hello();
return message;
}
}
beehive_tutorial\src\build.xml
so it appears as follows. Code to add appears in bold.. . .
<target name="init" depends="init.app.libs,init.dirs">
<path id="app.classpath">
<pathelement location="${src.dir}/APP-INF/classes"/>
<pathelement location="${dest.dir}/APP-INF/classes"/>
<pathelement path="${app.lib.classpath}"/>
<fileset dir="${src.dir}/APP-INF/lib">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${dest.dir}/APP-INF/lib">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${beehive.home}/apache-beehive-svn-snapshot/lib/netui">
<include name="**/*.jar"/>
<exclude name="**/beehive-netui-compiler.jar"/>
</fileset>
</path>
<!-- Merge the application.xml file with the auto-generated
application.xml file created by the web service compilation
process. -->
<copy todir="${dest.dir}/META-INF">
<fileset dir="${src.dir}/META-INF"/>
</copy>
</target>
...
<target name="compile" depends="init,compile.helloWorldControl,compile.helloWorldService,
compile.myWebApp"/>
...
<target name="compile.helloWorldService" depends="init" >
<taskdef name="jwsc" classname="weblogic.wsee.tools.anttasks.JwscTask"/>
<jwsc
verbose="true"
tempdir="${tmp.dir}"
destdir="${dest.dir}"
keepgenerated="true"
srcdir="${basedir}/services">
<jws file="pkg/HelloWorldService.java" name="HelloWorldService" explode="true"/>
<classpath>
<path refid="app.classpath"/>
</classpath>
</jwsc>
</target>
</project>
setDomainEnv.cmd
or setDomainEnv.sh
:ant clean build pkg.exploded
ant deploy.exploded
http://localhost:7001/HelloWorldService/HelloWorldService
To see the web service’s WSDL, visit the following URL:
http://localhost:7001/HelloWorldService/HelloWorldService?WSDL
![]() ![]() ![]() |