pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

如何在 Coldfusion8 中使用 javaloader 設置 java 庫?

How to setup java libraries with javaloader in Coldfusion8?(如何在 Coldfusion8 中使用 javaloader 設置 java 庫?)
本文介紹了如何在 Coldfusion8 中使用 javaloader 設置 java 庫?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在嘗試讓 javaLoader 在 Coldfusion8 應用程序中運行,我需要一些幫助才能讓我越過終點線.

I'm trying to get javaLoader to run in a Coldfusion8 application and I need some help to get me across the finish line.

這是我目前所擁有的:

application.cfc 內:

...
THIS.mappings["/javaloader"] = GetDirectoryFromPath( GetCurrentTemplatePath() ) & "tools/javaloader";
... 

<cffunction name="onApplicationStart" returnType="boolean" output="false" hint="application initalizer">
    <cfscript>
    Application.str = structNew();
    Application.str.myJavaLoaderKey = "someUUID_javaloader";
    Application.str.jarPaths = arrayNew(1);
    </cfscript>
    <cfif ( NOT structKeyExists(server, Application.str.myJavaLoaderKey) )>
        <!--- add path to class files to jarPath Array --->
        <cfset Application.str.jarPaths[1] = expandPath("/classes/BCrypt.class")>
        <!--- this will map out to: ...htdocs/classes/BCrypt.class --->

        <cfif ( NOT structKeyExists(server, Application.str.myJavaLoaderKey) )>
            <cflock name="#Hash(Application.str.myJavaLoaderKey)#" type="exclusive" timeout="10">
                <cfset server[Application.str.myJavaLoaderKey] = createObject("component", "javaloader.JavaLoader")>
                <!--- tried .init(Application.str.jarPaths) here, but didn't do anything --->
            </cflock>
        </cfif>
    </cfif>
    <cfreturn true />
</cffunction>

這是按照 這里和這里.

在我的 handler.cfc 中,我正在嘗試訪問 javaloader 和 BCrypt 類,如下所示:

In my handler.cfc, I'm trying to access javaloader and the BCrypt class like so:

<cfsript>
    pass = "some_password";
    <!--- this is accessible --->
    cryptonite = server[Application.str.myJavaLoaderKey];
    <!--- now trying to call init() with respective path to create an instance --->
    <!--- BREAKS HERE --->
    bCrypt = cryptonite.init(Application.str.jarPaths[1]);

    hashed = bCrypt.hashpw(pass, bcrypt.gensalt());        
</cfscript>                             

我可以轉儲cryptonite變量,但是當我嘗試創建BCrypt的實例時,腳本失敗了.

I can dump the cryptonite variable allright, but when I try to create the instance of BCrypt, the script fails.

問題:
我很高興我能做到這一點,但我已經坐了幾個小時了,不知道我做錯了什么.希望有更多見識的人可以為我指明方向?

Question:
I'm happy I made it this far, but I've been sitting on this for a few hours now with no clue what I'm doing wrong. Hopefully someone with more insight can point me in a direction?

感謝您的幫助!

推薦答案

好的.有幾個錯誤.

要使用 Coldfusion8 和 BCrypt 或您選擇的 Java 類設置 Javaloader,請執行以下操作:

To setup Javaloader with Coldfusion8 and BCrypt or a Java Class of your choice, do the following:

1) 將任何 Java 類(.java 文件,而不是 .class 文件)放在 webroot/htdocs(Apache) 的文件夾中.我的 BCrypt 路徑如下所示:

1) Put whatever Java Classes (the .java file, not the .class file) in a folder in your webroot/htdocs(Apache). My path for BCrypt looks like this:

  htdocs/classes/jBCrypt/

2) 對 javaloader 執行相同的操作.我的路徑如下所示:

2) Do the same for javaloader. My path looks like this:

  htdocs/tools/javaloader/

3) 在 Application.cfc 中:

<!--- create mapping to javaloder --->
<cfscript>        
    THIS.mappings["/javaloader"] = GetDirectoryFromPath( GetCurrentTemplatePath() ) & "tools/javaloader";
</cfscript>

<!--- Application start --->
<cffunction name="onApplicationStart" returnType="boolean" output="false" hint="">
    <cfscript>       
        <!--- store a UUID and emptry path array in Application scope --->
        Application.str = structNew(); 
        Application.str.myJavaLoaderKey = "your_uuid_javaloader";
        Application.str.jarPaths = arrayNew(1);
    </cfscript>
     <!--- check if exists --->
    <cfif ( NOT structKeyExists(server, Application.str.myJavaLoaderKey) )>

         <!--- put all paths to your .java files here, this is for JBCrypt --->
         <cfset Application.str.jarPaths[1] = expandPath("/classes/jBCrypt-0.3")>
         <cfif ( NOT structKeyExists(server, Application.str.myJavaLoaderKey) )>

            <cflock name="#Hash(Application.str.myJavaLoaderKey)#" type="exclusive" timeout="10">
                <!--- create javaloader object and init with all submitted paths --->
                <cfset server[Application.str.myJavaLoaderKey] = createObject("component", "javaloader.JavaLoader").init(sourceDirectories=Application.str.jarPaths )>
            </cflock>
        </cfif>
    </cfif>
</cffunction>

根據 這里.這應該設置您現在可以從其他地方引用的所有 .java 類,如下所示:

The setup should be in the application scope as per here. This should set up all .java classes which you can now reference from elsewhere like so:

<cfscript>
    var pass = "a_password";
    javaLoader = server[Application.str.myJavaLoaderKey];
    // create an instance of javaloader-BCrypt
    bcrypt = javaLoader.create("BCrypt").init();
    // now you can call methods from bcrypt like so:
    hashed = bcrypt.hashpw(pass, bcrypt.gensalt());
</cfscript>

通過這里了解它.原來你必須參考 .java 文件而不是 .class 文件,我最初是這樣做的.

Figured it out reading through here. Turns out you have to refer to the .java file and not the .class file, which I initally did.

以下鏈接也可能會有所幫助:
http://blog.mxunit.org/2011/02/hashing-passwords-with-bcrypt-in.html
http://www.compoundtheory.com/javaloader/docs/
http:///www.aliaspooryorik.com/blog/index.cfm/e/posts.details/post/using-bcrypt-in-coldfusion-10-370

The following links may also be helpful:
http://blog.mxunit.org/2011/02/hashing-passwords-with-bcrypt-in.html
http://www.compoundtheory.com/javaloader/docs/
http://www.aliaspooryorik.com/blog/index.cfm/e/posts.details/post/using-bcrypt-in-coldfusion-10-370

這篇關于如何在 Coldfusion8 中使用 javaloader 設置 java 庫?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to wrap text around components in a JTextPane?(如何在 JTextPane 中的組件周圍環繞文本?)
MyBatis, how to get the auto generated key of an insert? [MySql](MyBatis,如何獲取插入的自動生成密鑰?[MySql])
Inserting to Oracle Nested Table in Java(在 Java 中插入 Oracle 嵌套表)
Java: How to insert CLOB into oracle database(Java:如何將 CLOB 插入 oracle 數據庫)
Why does Spring-data-jdbc not save my Car object?(為什么 Spring-data-jdbc 不保存我的 Car 對象?)
Use threading to process file chunk by chunk(使用線程逐塊處理文件)
主站蜘蛛池模板: 小区健身器材_户外健身器材_室外健身器材_公园健身路径-沧州浩然体育器材有限公司 | 多功能干燥机,过滤洗涤干燥三合一设备-无锡市张华医药设备有限公司 | 科普仪器菏泽市教育教学仪器总厂 | 户外-组合-幼儿园-不锈钢-儿童-滑滑梯-床-玩具-淘气堡-厂家-价格 | 空气净化器租赁,空气净化器出租,全国直租_奥司汀净化器租赁 | 会议会展活动拍摄_年会庆典演出跟拍_摄影摄像直播-艾木传媒 | 球形钽粉_球形钨粉_纳米粉末_难熔金属粉末-广东银纳官网 | 空冷器|空气冷却器|空水冷却器-无锡赛迪森机械有限公司[官网] | 通信天线厂家_室分八木天线_对数周期天线_天线加工厂_林创天线源头厂家 | 不锈钢酒柜|恒温酒柜|酒柜定制|酒窖定制-上海啸瑞实业有限公司 | 土壤肥料养分速测仪_测土配方施肥仪_土壤养分检测仪-杭州鸣辉科技有限公司 | 喷码机,激光喷码打码机,鸡蛋打码机,手持打码机,自动喷码机,一物一码防伪溯源-恒欣瑞达有限公司 | 酒水灌装机-白酒灌装机-酒精果酒酱油醋灌装设备_青州惠联灌装机械 | 京港视通报道-质量走进大江南北-京港视通传媒[北京]有限公司 | 济南铝方通-济南铝方通价格-济南方通厂家-山东鲁方通建材有限公司 | 高低温试验房-深圳高低温湿热箱-小型高低温冲击试验箱-爱佩试验设备 | 量子管通环-自清洗过滤器-全自动反冲洗过滤器-北京罗伦过滤技术集团有限公司 | 北京模型公司-军事模型-工业模型制作-北京百艺模型沙盘公司 | 冷却塔改造厂家_不锈钢冷却塔_玻璃钢冷却塔改造维修-广东特菱节能空调设备有限公司 | 中国品牌排名投票_十大品牌榜单_中国著名品牌【中国品牌榜】 | 玉米深加工设备-玉米深加工机械-新型玉米工机械生产厂家-河南粮院机械制造有限公司 | 烟台金蝶财务软件,烟台网站建设,烟台网络推广 | 小型手持气象站-空气负氧离子监测站-多要素微气象传感器-山东天合环境科技有限公司 | UV-1800紫外光度计-紫外可见光度计厂家-翱艺仪器(上海)有限公司 | 杭州用友|用友软件|用友财务软件|用友ERP系统--杭州协友软件官网 | 浙江美尔凯特智能厨卫股份有限公司 | 上海新光明泵业制造有限公司-电动隔膜泵,气动隔膜泵,卧式|立式离心泵厂家 | 作文导航网_作文之家_满分作文_优秀作文_作文大全_作文素材_最新作文分享发布平台 | 制丸机,小型中药制丸机,全自动制丸机价格-甘肃恒跃制药设备有限公司 | 猪I型/II型胶原-五克隆合剂-细胞冻存培养基-北京博蕾德科技发展有限公司 | 设定时间记录电子秤-自动累计储存电子秤-昆山巨天仪器设备有限公司 | 杭州中策电线|中策电缆|中策电线|杭州中策电缆|杭州中策电缆永通集团有限公司 | wika威卡压力表-wika压力变送器-德国wika代理-威卡总代-北京博朗宁科技 | 金属检测机_金属分离器_检针验针机_食品药品金属检探测仪器-广东善安科技 | 非甲烷总烃分析仪|环控百科| 智慧消防-消防物联网系统云平台| 冲击式破碎机-冲击式制砂机-移动碎石机厂家_青州市富康机械有限公司 | 整车VOC采样环境舱-甲醛VOC预处理舱-多舱法VOC检测环境仓-上海科绿特科技仪器有限公司 | SEO网站优化,关键词排名优化,苏州网站推广-江苏森歌网络 | 合同书格式和范文_合同书样本模板_电子版合同,找范文吧 | 钢衬四氟管道_钢衬四氟直管_聚四氟乙烯衬里管件_聚四氟乙烯衬里管道-沧州汇霖管道科技有限公司 |