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(使用線程逐塊處理文件)
主站蜘蛛池模板: 珠宝展柜-玻璃精品展柜-首饰珠宝展示柜定制-鸿钛展柜厂家 | 工业铝型材-铝合金电机壳-铝排-气动执行器-山东永恒能源集团有限公司 | 全自动贴标机-套标机-工业热风机-不干胶贴标机-上海厚冉机械 | 台湾阳明固态继电器-奥托尼克斯光电传感器-接近开关-温控器-光纤传感器-编码器一级代理商江苏用之宜电气 | 灌木树苗-绿化苗木-常绿乔木-价格/批发/基地 - 四川成都途美园林 | 磁力去毛刺机_去毛刺磁力抛光机_磁力光饰机_磁力滚抛机_精密金属零件去毛刺机厂家-冠古科技 | 水冷式工业冷水机组_风冷式工业冷水机_水冷螺杆冷冻机组-深圳市普威机械设备有限公司 | 对夹式止回阀厂家,温州对夹式止回阀制造商--永嘉县润丰阀门有限公司 | 正压送风机-多叶送风口-板式排烟口-德州志诺通风设备 | 济南ISO9000认证咨询代理公司,ISO9001认证,CMA实验室认证,ISO/TS16949认证,服务体系认证,资产管理体系认证,SC食品生产许可证- 济南创远企业管理咨询有限公司 郑州电线电缆厂家-防火|低压|低烟无卤电缆-河南明星电缆 | 丝印油墨_水性油墨_环保油墨油漆厂家_37国际化工 | 台湾阳明固态继电器-奥托尼克斯光电传感器-接近开关-温控器-光纤传感器-编码器一级代理商江苏用之宜电气 | 天津暖气片厂家_钢制散热器_天津铜铝复合暖气片_维尼罗散热器 | 发电机价格|发电机组价格|柴油发电机价格|柴油发电机组价格网 | 海尔生物医疗四川代理商,海尔低温冰箱四川销售-成都壹科医疗器械有限公司 | 合肥汽车充电桩_安徽充电桩_电动交流充电桩厂家_安徽科帝新能源科技有限公司 | 铝合金脚手架厂家-专注高空作业平台-深圳腾达安全科技 | 离子色谱自动进样器-青岛艾力析实验科技有限公司 | 北京模型公司-军事模型-工业模型制作-北京百艺模型沙盘公司 | 蒸汽吸附分析仪-进口水分活度仪|康宝百科| 扬尘在线监测系统_工地噪声扬尘检测仪_扬尘监测系统_贝塔射线扬尘监测设备「风途物联网科技」 | 工业rfid读写器_RFID工业读写器_工业rfid设备厂商-ANDEAWELL | 钢板仓,大型钢板仓,钢板库,大型钢板库,粉煤灰钢板仓,螺旋钢板仓,螺旋卷板仓,骨料钢板仓 | 乙炔气体报警装置|固定式氯化氢检测仪|河南驰诚电气百科 | 筒瓦厂家-仿古瓦-寺庙-古建琉璃瓦-宜兴市古典园林建筑陶瓷厂有限公司 | 不锈钢复合板|钛复合板|金属复合板|南钢集团安徽金元素复合材料有限公司-官网 | 智慧旅游_智慧景区_微景通-智慧旅游景区解决方案提供商 | 合肥风管加工厂-安徽螺旋/不锈钢风管-通风管道加工厂家-安徽风之范 | 罗氏牛血清白蛋白,罗氏己糖激酶-上海嵘崴达实业有限公司 | 鼓风干燥箱_真空烘箱_高温干燥箱_恒温培养箱-上海笃特科学仪器 | 微型气象仪_气象传感器_防爆气象传感器-天合传感器大全 | 继电器模组-IO端子台-plc连接线-省配线模组厂家-世麦德 | 东莞猎头公司_深圳猎头公司_广州猎头公司-广东万诚猎头提供企业中高端人才招聘服务 | 提升海外网站流量,增加国外网站访客UV,定制海外IP-访客王 | ◆大型吹塑加工|吹塑加工|吹塑代加工|吹塑加工厂|吹塑设备|滚塑加工|滚塑代加工-莱力奇塑业有限公司 | 炒货机-炒菜机-炒酱机-炒米机@霍氏机械 | 熔体泵|换网器|熔体齿轮泵|熔体计量泵厂家-郑州巴特熔体泵有限公司 | 低温等离子清洗机(双气路进口)-嘉润万丰| Safety light curtain|Belt Sway Switches|Pull Rope Switch|ultrasonic flaw detector-Shandong Zhuoxin Machinery Co., Ltd | 长城人品牌官网 | 哈尔滨京科脑康神经内科医院-哈尔滨治疗头痛医院-哈尔滨治疗癫痫康复医院 |