Whatever message this page gives is out now! Go check it out!
THIS.javaSettings = {LoadPaths = [".\java_lib\",".\java\myjar.jar"], loadColdFusionClassPath = true, reloadOnChange = false} |
Parameter | Description |
loadPaths | An array of paths to the directories that contain Java classes or JAR files.You can also provide the path to a JAR or a class. If the paths are not resolved, an error occurs. |
loadColdFusionClassPath | Indicates whether to load the classes from the ColdFusion lib directory. The default value is false. |
reloadOnChange | Indicates whether to reload the updated classes and JARs dynamically, without restarting ColdFusion. The default value is false. |
THIS.javaSettings = {LoadPaths = [".\java_lib\",".\java\myjar.jar"], loadColdFusionClassPath = true, reloadOnChange= true, watchInterval = 100, watchExtensions = "jar,class,xml"} |
Parameter | Description |
loadPaths | An array of paths to the directories that contain Java classes or JAR files.You can also provide the path to a JAR or a class. If the paths are not resolved, an error occurs. |
loadColdFusionClassPath | Indicates whether to load the classes from the ColdFusion lib directory. The default value is false. |
reloadOnChange | Indicates whether to reload the updated classes and JARs dynamically, without restarting ColdFusion. The default value is false. |
watchInterval | Specifies the time interval in seconds after which to verify any change in the class files or JAR files. This attribute is applicable only if the reloadOnChange attribute is set to true. The default value is 60 seconds. |
watchExtensions | Specifies the extensions of the files to monitor for changes. By default, only .class and .jar files are monitored. |
public class Test
{
public String testJava()
{
return "Hello Java!!";
}
}<cfset THIS.javaSettings = {LoadPaths = ["/myJava/lib"],reloadOnChange=true,watchInterval=30}/> |
/myJava/lib |
<cfobject type="java" class="Test" name="myObj">
<cfset y = myObj.init()>
<cfoutput >
#y.testJava()#
</cfoutput>CFCProxy(String fully-qualified-path-of-CFC-file) |
CFCProxy(String fully-qualified-path-of-CFC-file name-value-pairs) |
import coldfusion.cfc.CFCProxy;
public class CFCInvoker
{
public String directInvoke(String cfcPath)
{
String myMessage = "";
try
{
CFCProxy myCFC = new CFCProxy(cfcPath, true);
Object[] myArgs = { "Hello" };
myMessage = (String)myCFC.invoke("getData", myArgs);
}
catch (Throwable e)
{
e.printStackTrace();
}
return myMessage;
}
}<cfcomponent>
<cffunction name="getData" returntype="string">
<cfargument name="msg" required="Yes">
<cfreturn msg & "Java" />
</cffunction>
</cfcomponent>THIS.javaSettings = {LoadPaths = ["/lib"],reloadOnChange= true,loadColdFusionClassPath=true}; |
<cfobject action="create" type="java" class="CFCInvoker" name="x">
<cfset cfcPath = "C:\ColdFusion10\cfusion\wwwroot\Project\name.cfc"/>
<cfset y = x.directInvoke2(cfcPath)>
<cfoutput>#y#</cfoutput>createDynamicProxy("fullyQualifiedNameOfCFC", ["interfaceName"]); |
public interface MyInterface
{
public String sayHello();
}public class InvokeHelloProxy
{
private MyInterface myInterface;
public InvokeHelloProxy(MyInterface x)
{
this.myInterface = x;
}
public String invokeHello()
{
return myInterface.sayHello();
}
}<cfcomponent>
<cffunction name="sayHello" returntype="string">
<cfreturn "Hello World!!!!">
</cffunction>
</cfcomponent><cfset THIS.javaSettings = {LoadPaths = ["/lib"],reloadOnChange=true,watchInterval=10}/> |
<cfset dynInstnace = createDynamicProxy("cfc.HelloWorld", ["MyInterface"])>
<cfset x = createObject("java","InvokeHelloProxy").init(dynInstnace)>
<cfset y = x.invokeHello()>
<cfoutput>#y#</cfoutput><cfset instance=new cfc.helloWorld()>
<cfset dynInstnace = createDynamicProxy(instance, ["MyInterface"])>
<cfset x = createObject("java","InvokeHelloProxy").init(dynInstnace)>
<cfset y = x.invokeHello()>
<cfoutput>#y#</cfoutput>