|
XCC/J 4.0-9 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.marklogic.xcc.jndi.ContentSourceBeanFactory
public class ContentSourceBeanFactory
This class implements the JNDI ObjectFactory interface
and may be used in a J2EE container as a source of
ContentSource instances.
This class is preferred over ContentSourceBean
if you have the option because it does a little more
consistency checking when creating new objects. Neither
does it depend on a container-provided bean factory.
JNDI resources are typically specified as part of the
container configuration. The specifics of configuration
vary by container. Below is an example of using this
class with Apache
Tomcat version 5.5
to configure a ContentSource.
Further details of JNDI configuration in Tomcat are available on the
JNDI-HowTo page.
There are two places where JNDI resources can be configured in the Tomcat 5.5 container. One is globally in Tomcat's config file in $CATALINA_HOME/conf/server.xml, the other is within an individual webapp in META-INF/context.xml. In either file, an XML element like this should be placed as a child of the <Context> element, like this:
<Context path="/">
<Resource name="marklogic/ContentSource" auth="Container"
type="com.marklogic.xcc.ContentSource"
factory="com.marklogic.xcc.jndi.ContentSourceBeanFactory"
host="somehost.mycorp.com" port="8003" user="fred" password="hush"
contentbase="productiondb"/>
<Context>
An alternate means of specifying the content source is via the "url" attribute, like this:
<Context path="/">
<Resource name="marklogic/ContentSource" auth="Container"
type="com.marklogic.xcc.ContentSource"
factory="com.marklogic.xcc.jndi.ContentSourceBeanFactory"
url="xcc://fred:hush@somehost.mycorp.com:8003/productiondb"/>
<Context>
The value of the "name" attribute is the JNDI lookup key
that you will use in your code (servlet, JSP scriptlet, etc)
to locate the ContentSource. A
typical method to do the lookup would look something like this:
private ContentSource findContentSource() throws ServletException
{
try {
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
return (ContentSource) envCtx.lookup ("marklogic/ContentSource");
} catch (NamingException e) {
throw new ServletException ("ContentSource lookup failed: " + e, e);
}
}
| Constructor Summary | |
|---|---|
ContentSourceBeanFactory()
|
|
| Method Summary | |
|---|---|
Object |
getObjectInstance(Object obj,
Name name,
Context nameCtx,
Hashtable environment)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ContentSourceBeanFactory()
| Method Detail |
|---|
public Object getObjectInstance(Object obj,
Name name,
Context nameCtx,
Hashtable environment)
throws Exception
getObjectInstance in interface ObjectFactoryException
|
XCC/J 4.0-9 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Complete online documentation for MarkLogic Server, XQuery and related components may be found at developer.marklogic.com