コード例 #1
0
def isExistingJNDI(jndi, configProperties):
	# Look up connection factory and queue in JNDI.

	# check configuration properties

	webLogicAdminURL=configProperties.getProperty('webLogicAdmin.URL')

	properties = Properties()
	properties[Context.PROVIDER_URL] = webLogicAdminURL
	properties[Context.INITIAL_CONTEXT_FACTORY] = WLInitialContextFactory.name
	
	initialContext = InitialContext(properties)
	
	log.info('Preforming JNDI lookup for [' + jndi + ']')
	
	found = true
	
	try:
		jndiLookup = initialContext.lookup(jndi)
	except NameNotFoundException, error:
		found = false
コード例 #2
0
def send_jms(request):
    """
    This just grabs the JMS queue and sends a message to it.
    """
    context = InitialContext()
    tfactory = context.lookup("jms/MyConnectionFactory")

    tconnection = tfactory.createTopicConnection()
    tsession = tconnection.createTopicSession(False, Session.AUTO_ACKNOWLEDGE)
    publisher = tsession.createPublisher(context.lookup("jms/MyFirstTopic"))

    message = tsession.createTextMessage()
    msg = "Hello there buddy: %s" % datetime.datetime.now()
    message.setText(msg)
    publisher.publish(message, DeliveryMode.PERSISTENT, 
            Message.DEFAULT_PRIORITY,
            20000,
            )

    context.close()
    tconnection.close()
    return render_to_response('backend/send_jms.html', {'msg': msg})
コード例 #3
0
    def go(self):
        props = Properties()
        props.put(Context.INITIAL_CONTEXT_FACTORY,
                  "com.sun.appserv.naming.S1ASCtxFactory")
        props.put(Context.PROVIDER_URL, "iiop://127.0.0.1:3700")

        context = InitialContext(props)
        tfactory = context.lookup("jms/MyConnectionFactory")

        tconnection = tfactory.createTopicConnection('receiver', 'receiver')
        tconnection.setClientID('myClientId:recv')
        tsession = tconnection.createTopicSession(False,
                                                  Session.AUTO_ACKNOWLEDGE)

        subscriber = tsession.createDurableSubscriber(
            context.lookup("jms/MyFirstTopic"), 'mysub')

        subscriber.setMessageListener(self)

        tconnection.start()

        while True:
            time.sleep(1)
コード例 #4
0
ファイル: producer.py プロジェクト: rparree/jboss-esb-demos
from javax.naming import InitialContext 
from javax.jms import *
from java.util import Properties

numberOfMessage = 10
messageText = "hello"

properties = Properties()
properties.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory")
properties.put("java.naming.provider.url","jnp://localhost:1099")
properties.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces")

context = InitialContext(properties)
factory =context.lookup("ConnectionFactory")
destination = context.lookup("queue/DemoJMSProviderGW")

connection =  factory.createConnection()
session = connection.createSession(False, Session.AUTO_ACKNOWLEDGE)
producer = session.createProducer(destination)

for i in range(numberOfMessage):
  producer.send(session.createTextMessage(messageText+' ' + `i`))



コード例 #5
0
ファイル: jndi.py プロジェクト: walkabout21/OpenModelSphere
# $Id: jndi.py 1962 2001-12-14 04:20:03Z bzimmer $
#
# Copyright (c) 2001 brian zimmer <*****@*****.**>
"""
	This script is used to bind a JNDI reference for testing purposes only.
"""
from java.util import Hashtable
from org.gjt.mm.mysql import MysqlDataSource
from javax.naming import Context, InitialContext, NameAlreadyBoundException

env = Hashtable()
env.put(Context.INITIAL_CONTEXT_FACTORY,
        "com.sun.jndi.fscontext.RefFSContextFactory")

ds = MysqlDataSource()
ds.setServerName("localhost")
ds.setDatabaseName("ziclix")
ds.setPort(3306)

ctx = InitialContext(env)
try:
    try:
        ctx.bind("/jdbc/mysqldb", ds)
    except NameAlreadyBoundException, e:
        ctx.unbind("/jdbc/mysqldb")
        ctx.bind("/jdbc/mysqldb", ds)
finally:
    ctx.close()

print "bound [%s] at /jdbc/mysqldb" % (ds)
コード例 #6
0
ファイル: ejb.py プロジェクト: nmonga91/swe-737-load-testing
from javax.naming import Context, InitialContext
from net.grinder.script.Grinder import grinder
from net.grinder.script import Test
from weblogic.jndi import WLInitialContextFactory

tests = {
    "home": Test(1, "TraderHome"),
    "trade": Test(2, "Trader buy/sell"),
    "query": Test(3, "Trader getBalance"),
}

# Initial context lookup for EJB home.
p = Properties()
p[Context.INITIAL_CONTEXT_FACTORY] = WLInitialContextFactory.name

home = InitialContext(p).lookup("ejb20-statefulSession-TraderHome")
tests["home"].record(home)

random = Random()


class TestRunner:
    def __call__(self):
        log = grinder.logger.info

        trader = home.create()
        tests["trade"].record(trader.sell)
        tests["trade"].record(trader.buy)
        tests["query"].record(trader.getBalance)

        stocksToSell = {"BEAS": 100, "MSFT": 999}
コード例 #7
0
package org.jboss.book.jca.ex1;

import javax.naming.InitialContext;

public class ExClient
{
   public static void main(String args[]) 
       throws Exception
   {
      InitialContext iniCtx = new InitialContext();
      Object         ref    = iniCtx.lookup("EchoBean");
      EchoHome       home   = (EchoHome) ref;
      Echo           echo   = home.create();

      System.out.println("Created Echo");

      System.out.println("Echo.echo('Hello') = " + echo.echo("Hello"));
   }
}