alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

jforum example source code file (1.txt)

This example jforum source code file (1.txt) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - jforum tags/keywords

a, by, creating, forumcontext, forumcontext, http, http, in, integrating, jdbc, jforum, jforum, request, the

The jforum 1.txt source code

!!! Integrating JForum
JForum uses [ThreadLocal|http://www.ibm.com/developerworks/java/library/j-threads3.html] for its execution contexts, which is where all the action occurs. In order to execute anything related to JForum, you have to setup the execution context, represented by the class ''net.jforum.JForumExecutionContext''. The most common used methods are ''get()'', ''set()'', ''setConnection()'', and ''setForumContext()'', this last being an instance of ''net.jforum.context.ForumContext'', usually ''net.jforum.context.JForumContext''. 

A ''ForumContext'' contains the HTTP Request and Response, as well the ''context path' and JForum's servlet extension. 

!! Creating a ''complete' execution context
By ''complete'' we mean an execution context that has a request, response and JDBC connection. Not every time you will need all this information - it depends of what you are trying to do -, but it is very likely that at least the HTTP request will be necessary. 

[{Java2HtmlPlugin 

import net.jforum.JForumExecutionContext;
import net.jforum.context.ForumContext;
import net.jforum.context.JForumContext;
import net.jforum.context.web.WebRequestContext;
import net.jforum.context.web.WebResponseContext;

// .....

try {
	// Retrieve an existing or create a new execution context
	JForumExecutionContext executionContext = JForumExecutionContext.get();
	
	// Create a ForumContext
	ForumContext forumContext = new JForumContext(request.getContextPath(), 
		".page", 
		new WebRequestContext(request), 
		new WebResponseContext(response));
	
	executionContext.setForumContext(forumContext);
	
	// If you have a valid JDBC connection at this point, you can 
	// set it as well
	executionContext.setConnection(connection);
	
	// Set back the new execution context, so we can use it
	JForumExecutionContext.set(executionContext);
	
	// ....
	// Execute all your JForum code here
	// ....
}
finally {
	// Release the resources
	JForumExecutionContext.finish();
}
}]

Other jforum examples (source code examples)

Here is a short list of links related to this jforum 1.txt source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.