Skip to content

Commit 7fb6287

Browse files
author
Jim Leether
committed
Downgraded slf4j jar files
Had to downgrade slf4j to version 1.5.6 for compatability with ColdFusion 9
1 parent c1a91ce commit 7fb6287

File tree

9 files changed

+58
-97
lines changed

9 files changed

+58
-97
lines changed

Application.cfc

+32-33
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,32 @@
1-
<cfset THIS.name = "cfsolrlibDemo" />
2-
3-
<cffunction name="onApplicationStart">
4-
<cfscript>
5-
// load libraries needed for solrj
6-
var paths = arrayNew(1);
7-
arrayAppend(paths,expandPath("solrj-lib/solr-solrj-4.0.0.jar"));
8-
arrayAppend(paths,expandPath("solrj-lib/commons-io-2.4.jar"));
9-
arrayAppend(paths,expandPath("solrj-lib/commons-codec-1.7.jar"));
10-
arrayAppend(paths,expandPath("solrj-lib/slf4j-api-1.6.6.jar"));
11-
arrayAppend(paths,expandPath("solrj-lib/slf4j-jdk14-1.6.6.jar"));
12-
arrayAppend(paths,expandPath("solrj-lib/jcl-over-slf4j-1.6.6.jar"));
13-
arrayAppend(paths,expandPath("solrj-lib/log4j-over-slf4j-1.6.6.jar"));
14-
arrayAppend(paths,expandPath("solrj-lib/httpclient-4.2.1.jar"));
15-
arrayAppend(paths,expandPath("solrj-lib/httpcore-4.2.2.jar"));
16-
arrayAppend(paths,expandPath("solrj-lib/httpmime-4.2.1.jar"));
17-
arrayAppend(paths,expandPath("solrj-lib/stax-api-1.0.1.jar"));
18-
arrayAppend(paths,expandPath("solrj-lib/wstx-asl-4.0.0.jar"));
19-
arrayAppend(paths,expandPath("solrj-lib/tika-app-1.2.jar"));
20-
21-
// create an application instance of JavaLoader
22-
APPLICATION.javaloader = createObject("component", "javaloader.JavaLoader").init(loadpaths=paths, loadColdFusionClassPath=true);
23-
// setup tika
24-
APPLICATION.tika = APPLICATION.javaloader.create("org.apache.tika.Tika").init();
25-
26-
</cfscript>
27-
</cffunction>
28-
29-
<cffunction name="onRequestStart">
30-
<cfif structKeyExists(url, "reinit")>
31-
<cfset onApplicationStart()>
32-
</cfif>
33-
</cffunction>
1+
<cfset THIS.name = "cfsolrlibDemo" />
2+
3+
<cffunction name="onApplicationStart">
4+
<cfscript>
5+
// load libraries needed for solrj
6+
var paths = arrayNew(1);
7+
arrayAppend(paths,expandPath("solrj-lib/solr-solrj-4.0.0.jar"));
8+
arrayAppend(paths,expandPath("solrj-lib/commons-io-2.4.jar"));
9+
arrayAppend(paths,expandPath("solrj-lib/commons-codec-1.7.jar"));
10+
arrayAppend(paths,expandPath("solrj-lib/slf4j-api-1.5.6.jar"));
11+
arrayAppend(paths,expandPath("solrj-lib/slf4j-jdk14-1.5.6.jar"));
12+
arrayAppend(paths,expandPath("solrj-lib/jcl-over-slf4j-1.5.6.jar"));
13+
arrayAppend(paths,expandPath("solrj-lib/httpclient-4.2.1.jar"));
14+
arrayAppend(paths,expandPath("solrj-lib/httpcore-4.2.2.jar"));
15+
arrayAppend(paths,expandPath("solrj-lib/httpmime-4.2.1.jar"));
16+
arrayAppend(paths,expandPath("solrj-lib/stax-api-1.0.1.jar"));
17+
arrayAppend(paths,expandPath("solrj-lib/wstx-asl-4.0.0.jar"));
18+
arrayAppend(paths,expandPath("solrj-lib/tika-app-1.2.jar"));
19+
20+
// create an application instance of JavaLoader
21+
APPLICATION.javaloader = createObject("component", "javaloader.JavaLoader").init(loadpaths=paths, loadColdFusionClassPath=true);
22+
// setup tika
23+
APPLICATION.tika = APPLICATION.javaloader.create("org.apache.tika.Tika").init();
24+
25+
</cfscript>
26+
</cffunction>
27+
28+
<cffunction name="onRequestStart">
29+
<cfif structKeyExists(url, "reinit")>
30+
<cfset onApplicationStart()>
31+
</cfif>
32+
</cffunction>

index.cfm

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
<ul>
6161
<li><a href="indexExample.cfm">Indexing Example</a> (requires the CFArtGallery datasource)</li>
6262
<li><a href="searchExample.cfm">Search Example</a></li>
63+
<li><a href="autoSuggestExample.cfm">Auto Suggest Example</a> (Shows how to use JQuery Autocomplete with Solr)
6364
</ul>
6465

6566
<p>The point of the examples is the CF code, not the HTML that you'll see in the browser, so be sure to dig in!</p>

javaloader/JavaLoader.cfc

+20-60
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ Purpose: Utlitity class for loading Java Classes
104104

105105
<cffunction name="switchThreadContextClassLoader" hint="Sometimes you will need to switch out the ThreadContextClassLoader with the classloader used by JavaLoader.<br/>
106106
It has :
107-
switchThreadContextClassLoader(function object, [struct function arguments], [classLoader=getURLClassLoader()])
108-
switchThreadContextClassLoader(function name, [struct function arguments], [classLoader=getURLClassLoader()])
109-
switchThreadContextClassLoader(object, function name, [struct function arguments], [classLoader=getURLClassLoader()])
107+
switchThreadContextClassLoader(function object, [classLoader=getURLClassLoader()])
108+
switchThreadContextClassLoader(function name, [classLoader=getURLClassLoader()])
109+
switchThreadContextClassLoader(object, function name, [classLoader=getURLClassLoader()])
110110
This method can be used in 3 different ways:
111111
<ol>
112112
<li>Pass it the UDF itself</li>
@@ -116,61 +116,21 @@ Purpose: Utlitity class for loading Java Classes
116116
access="public" returntype="any" output="false">
117117
<cfscript>
118118
var local = {};
119-
var func = 0; //need this as cf8 doesn't like the structure with functions.
120119
var System = createObject("java", "java.lang.System");
121120
var Thread = createObject("java", "java.lang.Thread");
122121
var currentClassloader = Thread.currentThread().getContextClassLoader();
123-
var classLoader = "";
124-
125-
if (structCount(arguments) == 4)
126-
{
127-
// the last 2 arguments are the function arguments and class loader
128-
classLoader = arguments[4];
129-
local.funcArgs = arguments[3];
130-
}
131-
else if (structCount(arguments) == 3)
132-
{
133-
// 2nd argument could be classloader or function arguments
134-
if (isInstanceOf(arguments[2],"java.lang.ClassLoader"))
135-
{
136-
classLoader = arguments[2];
137-
}
138-
else if (isStruct(arguments[2]))
139-
{
140-
local.funcArgs = arguments[2];
141-
}
142-
143-
// 3rd argument could be classloader or function arguments
144-
if (isInstanceOf(arguments[3],"java.lang.ClassLoader"))
145-
{
146-
classLoader = arguments[3];
147-
}
148-
else if (isStruct(arguments[3]))
149-
{
150-
local.funcArgs = arguments[3];
151-
}
152-
}
153-
else if (structCount(arguments) == 2)
154-
{
155-
// the 2nd argument could be a class loader or function arguments
156-
if (isInstanceOf(arguments[2],"java.lang.ClassLoader"))
157-
{
158-
classLoader = arguments[2];
159-
}
160-
else if (isStruct(arguments[2]))
161-
{
162-
local.funcArgs = arguments[2];
163-
}
122+
123+
if(structCount(arguments) == 2 && !isSimpleValue(arguments[2]))
124+
{
125+
classLoader = arguments[2];
164126
}
165-
166-
if (!structKeyExists(local,"funcArgs"))
127+
else if(structCount(arguments) == 3)
167128
{
168-
local.funcArgs = {};
129+
classLoader = arguments[3];
169130
}
170-
171-
if (isSimpleValue(classLoader))
131+
else //assume we are still in JL
172132
{
173-
classLoader = getURLClassLoader();
133+
classLoader = getURLClassLoader();
174134
}
175135
</cfscript>
176136

@@ -180,14 +140,14 @@ Purpose: Utlitity class for loading Java Classes
180140
</cfscript>
181141

182142
<cfif isSimpleValue(arguments[1])>
183-
<cfinvoke method="#arguments[1]#" returnvariable="local.return" argumentCollection="#local.funcArgs#" />
143+
<cfinvoke method="#arguments[1]#" returnvariable="local.return" />
184144
<cfelseif isCustomFunction(arguments[1])>
185145
<cfscript>
186-
func = arguments[1];
187-
local.return = func(argumentCollection = local.funcArgs);
146+
local.func = arguments[1];
147+
local.return = local.func();
188148
</cfscript>
189149
<cfelseif isObject(arguments[1]) AND isSimpleValue(arguments[2])>
190-
<cfinvoke component="#arguments[1]#" method="#arguments[2]#" returnvariable="local.return" argumentCollection="#local.funcArgs#" />
150+
<cfinvoke component="#arguments[1]#" method="#arguments[2]#" returnvariable="local.return" />
191151
<cfelse>
192152
<cfthrow type="javaloader.InvalidInvocationException" message="Unable to determine what method to invoke" detail="Please check the documentation for switchThreadContextClassLoader."/>
193153
</cfif>
@@ -315,7 +275,7 @@ Purpose: Utlitity class for loading Java Classes
315275
for(; counter lte len; counter = counter + 1)
316276
{
317277
dir = directories[counter];
318-
$directoryCopy(dir, path);
278+
directoryCopy(dir, path);
319279
}
320280

321281
//then we compile it, and grab that jar
@@ -478,11 +438,11 @@ Purpose: Utlitity class for loading Java Classes
478438
<cfdirectory action="list" name="qJars" directory="#path#" filter="*.jar" sort="name desc"/>
479439
<cfloop query="qJars">
480440
<cfscript>
481-
libName = ListGetAt(qJars.name, 1, "-");
441+
libName = ListGetAt(name, 1, "-");
482442
//let's not use the lib's that have the same name, but a lower datestamp
483443
if(NOT ListFind(jarList, libName))
484444
{
485-
ArrayAppend(aJars, path & "/" & qJars.name);
445+
ArrayAppend(aJars, path & "/" & name);
486446
jarList = ListAppend(jarList, libName);
487447
}
488448
</cfscript>
@@ -584,7 +544,7 @@ Copies a directory.
584544
@author Joe Rinehart ([email protected])
585545
@version 1, July 27, 2005
586546
--->
587-
<cffunction name="$directoryCopy" access="private" output="true">
547+
<cffunction name="directoryCopy" access="private" output="true">
588548
<cfargument name="source" required="true" type="string">
589549
<cfargument name="destination" required="true" type="string">
590550
<cfargument name="nameconflict" required="true" default="overwrite">
@@ -602,7 +562,7 @@ Copies a directory.
602562
<cfif contents.type eq "file">
603563
<cffile action="copy" source="#arguments.source#/#name#" destination="#arguments.destination#/#name#" nameconflict="#arguments.nameConflict#">
604564
<cfelseif contents.type eq "dir">
605-
<cfset $directoryCopy(arguments.source & dirDelim & name, arguments.destination & dirDelim & name) />
565+
<cfset directoryCopy(arguments.source & dirDelim & name, arguments.destination & dirDelim & name) />
606566
</cfif>
607567
</cfloop>
608568
</cffunction>
7.21 KB
Binary file not shown.

searchExample.cfm

+5-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<cfset local.params["hl.fragmentsBuilder"] = "colored">
1212
<cfset local.params["hl.boundaryScanner"] = "default">
1313
<cfset local.params["hl.usePhraseHighlighter"] = true>
14-
<cfset searchResponse = sampleSolrInstance.search(URL.q,0,100,local.params,"title") />
14+
<cfset searchResponse = sampleSolrInstance.search(URL.q,0,100,"title",local.params) />
1515
<cfelse>
1616
<cfset searchResponse = sampleSolrInstance.search(URL.q,0,100) />
1717
</cfif>
@@ -23,16 +23,17 @@
2323
</head>
2424
<body>
2525
<h2>Search Example</h2>
26-
<p>Here is a simple search example.</p>
26+
<p>Here is a simple search example.<br>
27+
When using highlighting, the highlighting will appear on the "Title" field.</p>
2728
<form action="" method="GET">
2829
Search: <input name="q" value="#URL.q#" /><br />
2930
Enable Highlighting: <input name="enableHighlighting" type="checkbox" /><br />
3031
<input type="submit" value="Search" /><br />
3132
Other Search Examples: <a href="searchExample.cfm?q=*:*">*:*</a> | <a href="searchExample.cfm?q=Charcoal">Charcoal</a> | <a href="searchExample.cfm?q=Media">Media</a>
3233
</form>
3334
<p>
34-
<cfloop array="#searchResponse.results#" index="currentResult">
35-
<strong>ID:</strong> #currentResult.id# <strong>TITLE:</strong> #currentResult.title#<br/>
35+
<cfloop array="#searchResponse.results#" index="currentResult">
36+
<strong>ID:</strong> #currentResult.id# <strong>TITLE:</strong> #currentResult.title#<br/>
3637
<cfif structKeyExists(url,"enableHighlighting")>
3738
<strong>HIGHLIGHTING:</strong> <cfif structKeyExists(currentResult,"highlightingResult")>#currentResult.highlightingResult[1]#</cfif><br/>
3839
</cfif>
Binary file not shown.

solrj-lib/jcl-over-slf4j-1.5.6.jar

16.3 KB
Binary file not shown.

solrj-lib/slf4j-api-1.5.6.jar

21.8 KB
Binary file not shown.

solrj-lib/slf4j-jdk14-1.5.6.jar

8.61 KB
Binary file not shown.

0 commit comments

Comments
 (0)