THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
This ContextFactory uses a java properties formatted file to setup initial values. This is the example properties file
JNDI Property setup
By setting the JNDI Initial Context Factory and URL as below it is possible to load any File from the locally mounted file system to use for JNDI purposes. The format of the file is described in the next section.
No Format |
---|
java.naming.factory.initial = org.apache.qpid.jndi.PropertiesFileInitialContextFactory
java.naming.provider.url = <path to JNDI File>
|
By simply setting these two system properties you can jump straight to the InitialContext creation in your code.
Example properties file
This is the example properties file.
No Format |
---|
# use the following property to configure the default connector
#java.naming.provider.url - ignored.
# register some connection factories
# connectionfactory.[jndiname] = [ConnectionURL]
connectionfactory.local = amqp://guest:guest@clientid/testpath?brokerlist='vm://:1'
# register some queues in JNDI using the form
# queue.[jndiName] = [physicalName]
queue.MyQueue = example.MyQueue
# register some topics in JNDI using the form
# topic.[jndiName] = [physicalName]
topic.ibmStocks = stocks.nyse.ibm
# Register an AMQP destination in JNDI
# NOTE: Qpid currently only supports direct,topics and headers
# destination.[jniName] = [BindingURL]
destination.direct = direct://amq.direct//directQueue
|
...
Code Block | ||||
---|---|---|---|---|
| ||||
//Ensure Loadyou thehave propertiesyour filesystem ...properties set Properties properties = new Properties(); properties.load(propertiesfile_inputStreamfinal String INITIAL_CONTEXT_FACTORY = "org.apache.qpid.jndi.PropertiesFileInitialContextFactory"; System.setProperty(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY); System.setProperty(Context.PROVIDER_URL, _JNDIFile); // Create the initial context Context ctx = new InitialContext(properties); // Perform the binds object = ctx.lookup(bindingValue); // Close the context when we're done ctx.close(); |
...