如何复制" ant run"使用appclient执行Glassfish ACC客户端

时间:2014-09-25 07:54:44

标签: java java-ee netbeans ant glassfish

如何在IDE外部运行appclient?虽然它seems possible to run stand-alone JNDI lookup apps from the CLIappclient,但它似乎不适用于ACC客户端。但是,它应该是可能的:

  

运行应用程序客户端

     

使用appclient脚本运行应用程序客户端   你可以使用appclient脚本启动ACC,   是否启用了Java Web Start。

GlassFish Server开源版 应用开发指南 4.0版 开发Java客户端10-15 第186页

步骤:

  

1。)创建了一个@Remote接口作为Java SE库API

     

2.。)创建了一个带有ejb模块的企业应用程序;添加接口API

     

3。)在ejb模块中,实现@Remote接口

     

4.)创建一个ACC应用程序;添加接口API;添加到企业应用程序

     

5.。)从IDE中插入ejb

     

6。)部署EAR,然后从IDE运行ACC客户端

这改编自Creating and Running an Application Client on the GlassFish Server

使用ant运行,来自CLI的“ant run”:

-run:
     [java] 2

run:

BUILD SUCCESSFUL
Total time: 28 seconds
thufir@dur:~/NetBeansProjects/SingletonACC$ 
在这种情况下,

是正确的输出。 (每次客户端运行时,整数都会增加1。)

我查看了ant文件,但是在这种情况下无法解读“ant run”的内容:

   <!--
                =================
                EXECUTION SECTION
                =================
            -->
    <target depends="dist,run-deploy,-as-retrieve-option-workaround,-init-run-macros,-run-pregfv3,-run" description="Run a main class." name="run"/>
    <target if="j2ee.appclient.tool.args" name="-run-pregfv3">
        <carproject:run-appclient-pregfv3/>
    </target>
    <target name="-run" unless="j2ee.appclient.tool.args">
        <carproject:run-appclient/>
    </target>
    <target depends="dist,run-deploy,-as-retrieve-option-workaround,-init-run-macros,-run-single-pregfv3,-run-single" description="Run a single class." name="run-single"/>
    <target depends="dist,run-deploy,-as-retrieve-option-workaround,-init-run-macros" name="-run-single" unless="j2ee.appclient.tool.args">
        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
        <carproject:run-appclient serverparams="${j2ee.appclient.tool.jvmoptions.class}${run.class}"/>
    </target>
    <target depends="dist,run-deploy,-as-retrieve-option-workaround,-init-run-macros" if="j2ee.appclient.tool.args" name="-run-single-pregfv3">
        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
        <carproject:run-appclient-pregfv3/>
    </target>
    <target depends="init" name="-init-run-macros">
        <macrodef name="run-appclient" uri="http://www.netbeans.org/ns/car-project/1">
            <attribute default="${application.args.param}" name="args"/>
            <attribute default="${j2ee.appclient.tool.jvmoptions}${client.jar}" name="serverparams"/>
            <element name="customize" optional="true"/>
            <sequential>
                <java dir="${basedir}" fork="true" jar="${client.jar}">
                    <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
                    <jvmarg line="@{serverparams}"/>
                    <jvmarg line="${run.jvmargs.param}"/>
                    <arg line="@{args}"/>
                    <syspropertyset>
                        <propertyref prefix="run-sys-prop."/>
                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
                    </syspropertyset>
                    <env key="APPCPATH" path="${javac.classpath}"/>
                    <sysproperty key="java.system.class.loader" value="org.glassfish.appclient.client.acc.agent.ACCAgentClassLoader"/>
                    <customize/>
                </java>
            </sequential>
        </macrodef>
        <macrodef name="run-appclient-pregfv3" uri="http://www.netbeans.org/ns/car-project/1">
            <element name="customize" optional="true"/>
            <sequential>
                <java classname="${j2ee.appclient.tool.mainclass}" fork="true">
                    <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
                    <jvmarg line="${j2ee.appclient.tool.jvmoptions}"/>
                    <jvmarg line="${run.jvmargs.param}"/>
                    <arg line="${j2ee.appclient.tool.args}"/>
                    <arg line="-client ${client.jar}"/>
                    <arg line="${application.args.param}"/>
                    <classpath>
                        <path path="${j2ee.platform.classpath}:${j2ee.appclient.tool.runtime}"/>
                    </classpath>
                    <syspropertyset>
                        <propertyref prefix="run-sys-prop."/>
                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
                    </syspropertyset>
                    <customize/>
                </java>
            </sequential>
        </macrodef>
    </target>
    <target if="j2ee.appclient.mainclass.args" name="-as-retrieve-option-workaround" unless="j2ee.clientName">
        <property name="client.jar" value="${dist.dir}/SingletonACCClient.jar"/>
        <sleep seconds="3"/>
        <copy failonerror="false" file="${wa.copy.client.jar.from}/SingletonACC/SingletonACCClient.jar" todir="${dist.dir}"/>
        <copy failonerror="false" flatten="true" todir="${dist.dir}/">
            <fileset dir="${wa.copy.client.jar.from}/SingletonACC" includes="**/SingletonACCClient.jar"/>
        </copy>
        <copy flatten="true" todir="${dist.dir}/SingletonACCClient">
            <fileset dir="${wa.copy.client.jar.from}/SingletonACC" includes="**/*.*ar"/>
        </copy>
        <copy failonerror="false" flatten="false" todir="${dist.dir}/SingletonACCClient">
            <fileset dir="${dist.dir}/gfdeploy/SingletonACC" includes="**/*.jar"/>
        </copy>
    </target>
    <target name="pre-run-deploy">
        <!-- Empty placeholder for easier customization. -->
        <!-- You can override this target in the ../build.xml file. -->
    </target>
    <target name="post-run-deploy">
        <!-- Empty placeholder for easier customization. -->
        <!-- You can override this target in the ../build.xml file. -->
    </target>
    <target name="-pre-nbmodule-run-deploy">
        <!-- Empty placeholder for easier customization. -->
        <!-- This target can be overriden by NetBeans modules. Don't override it directly, use -pre-run-deploy task instead. -->
    </target>
    <target name="-post-nbmodule-run-deploy">
        <!-- Empty placeholder for easier customization. -->
        <!-- This target can be overriden by NetBeans modules. Don't override it directly, use -post-run-deploy task instead. -->
    </target>
    <target name="-run-deploy-am">
        <!-- Task to deploy to the Access Manager runtime. -->
    </target>
    <target depends="init,compile,dist,pre-run-deploy,-pre-nbmodule-run-deploy,-run-deploy-nb,-init-deploy-ant,-deploy-ant,-run-deploy-am,-post-nbmodule-run-deploy,post-run-deploy,-do-update-breakpoints" name="run-deploy"/>
    <target if="netbeans.home" name="-run-deploy-nb">
        <nbdeploy clientUrlPart="${client.urlPart}" debugmode="false" forceRedeploy="${forceRedeploy}"/>
    </target>
    <target name="-init-deploy-ant" unless="netbeans.home">
        <property name="deploy.ant.archive" value="${dist.jar}"/>
        <property name="deploy.ant.resource.dir" value="${resource.dir}"/>
        <property name="deploy.ant.enabled" value="true"/>
    </target>
    <target depends="init,-run-undeploy-nb,-init-deploy-ant,-undeploy-ant" name="run-undeploy"/>
    <target if="netbeans.home" name="-run-undeploy-nb">
        <fail message="Undeploy is not supported from within the IDE"/>
    </target>
    <target depends="run-deploy,-init-display-browser,-display-browser-nb,-display-browser-cl" name="run-display-browser"/>
    <target if="do.display.browser" name="-init-display-browser">
        <condition property="do.display.browser.nb">
            <isset property="netbeans.home"/>
        </condition>
        <condition property="do.display.browser.cl">
            <and>
                <isset property="deploy.ant.enabled"/>
                <isset property="deploy.ant.client.url"/>
            </and>
        </condition>
    </target>
    <target if="do.display.browser.nb" name="-display-browser-nb">
        <nbbrowse url="${client.url}"/>
    </target>
    <target if="do.display.browser.cl" name="-get-browser" unless="browser">
        <condition property="browser" value="rundll32">
            <os family="windows"/>
        </condition>
        <condition else="" property="browser.args" value="url.dll,FileProtocolHandler">
            <os family="windows"/>
        </condition>
        <condition property="browser" value="/usr/bin/open">
            <os family="mac"/>
        </condition>
        <property environment="env"/>
        <condition property="browser" value="${env.BROWSER}">
            <isset property="env.BROWSER"/>
        </condition>
        <condition property="browser" value="/usr/bin/firefox">
            <available file="/usr/bin/firefox"/>
        </condition>
        <condition property="browser" value="/usr/local/firefox/firefox">
            <available file="/usr/local/firefox/firefox"/>
        </condition>
        <condition property="browser" value="/usr/bin/mozilla">
            <available file="/usr/bin/mozilla"/>
        </condition>
        <condition property="browser" value="/usr/local/mozilla/mozilla">
            <available file="/usr/local/mozilla/mozilla"/>
        </condition>
        <condition property="browser" value="/usr/sfw/lib/firefox/firefox">
            <available file="/usr/sfw/lib/firefox/firefox"/>
        </condition>
        <condition property="browser" value="/opt/csw/bin/firefox">
            <available file="/opt/csw/bin/firefox"/>
        </condition>
        <condition property="browser" value="/usr/sfw/lib/mozilla/mozilla">
            <available file="/usr/sfw/lib/mozilla/mozilla"/>
        </condition>
        <condition property="browser" value="/opt/csw/bin/mozilla">
            <available file="/opt/csw/bin/mozilla"/>
        </condition>
    </target>
    <target depends="-get-browser" if="do.display.browser.cl" name="-display-browser-cl">
        <fail unless="browser">
                    Browser not found, cannot launch the deployed application. Try to set the BROWSER environment variable.
                </fail>
        <property name="browse.url" value="${deploy.ant.client.url}${client.urlPart}"/>
        <echo>Launching ${browse.url}</echo>
        <exec executable="${browser}" spawn="true">
            <arg line="${browser.args} ${browse.url}"/>
        </exec>
    </target>
    <target depends="dist" name="verify">
        <nbverify file="${dist.jar}"/>
    </target>
    <target depends="init,compile-single" name="run-main">
        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
        <carproject:java classname="${run.class}"/>
    </target>
    <target depends="init" if="netbeans.home" name="-do-update-breakpoints">
        <carproject:nbjpdaappreloaded/>
    </target>

如何在IDE之外复制“ant run”

请注意SingletonAcc是单独部署的,即使它也是SingletonQueue企业应用程序的一部分,appclient企业应用程序也有thufir@dur:~/NetBeansProjects/SingletonACC$ thufir@dur:~/NetBeansProjects/SingletonACC$ /home/thufir/glassfish-4.1/glassfish/bin/asadmin list-applications SingletonQueue <ear, appclient, ejb> SingletonACC <appclient> Command list-applications executed successfully. thufir@dur:~/NetBeansProjects/SingletonACC$

{{1}}

1 个答案:

答案 0 :(得分:1)

您可以在ant中启用详细日志记录,以便查看实际执行的内容:

在NetBeans中转到Options - &gt; Tools - &gt; Java - &gt; Ant并将详细级别设置为调试

看起来ant只是在GlassFish上部署appclient(EntAppClient.jar)然后运行文件EntAppClientClient.jar(注意双客户端),其中包含一些类似于此的参数:

/java/jdk1.7.0/jre/bin/java.exe 
-Xbootclasspath/p:/NetBeans/enterprise/modules/ext/javaee6-endorsed/javax.annotation.jar;/NetBeans/enterprise/modules/ext/javaee6-endorsed/jaxb-api-osgi.jar;/NetBeans/enterprise/modules/ext/javaee6-endorsed/webservices-api-osgi.jar 
-Djava.endorsed.dirs=/glassfish410/glassfish/lib/endorsed;/glassfish410/glassfish/modules/endorsed 
-javaagent:/glassfish410/glassfish/lib/gf-client.jar=mode=acscript,arg=-configxml,arg=/glassfish410/glassfish/domains/domain1/config/glassfish-acc.xml,client=jar=dist/EntAppClientClient.jar 
-Djava.system.class.loader=org.glassfish.appclient.client.acc.agent.ACCAgentClassLoader 
-jar /EntAppClient/dist/EntAppClientClient.jar

希望这会有所帮助:)

相关问题