Giter Club home page Giter Club logo

wildfly-naming-client's Introduction

WildFly Naming Client

This simple JNDI/naming client library abstracts away some of the pain of JNDI by providing the following features:

  • Federation support
  • Class loader based provider extensibility
  • A replacement implementation of the jboss-remote-naming protocol
  • Abstract context implementations for supporting relative contexts and federation in custom naming providers

Usage

To use the WildFly naming client provider, the naming client initial context has to installed. This can be done in one of several different ways.

System property

If you set the system property java.naming.factory.initial to org.wildfly.naming.client.WildFlyInitialContextFactory, then your Java code to access an initial context is just:

    InitialContext ctx = new InitialContext();
    Blah blah = (Blah) ctx.lookup("foo:blah");

Environment property

You can also set the java.naming.factory.initial property on the environment. This property name is also found in the constant field javax.naming.Context#INITIAL_CONTEXT_FACTORY.

    Hashtable<String, Object> env = new Hashtable<>();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");
    InitialContext ctx = new InitialContext(env);
    Blah blah = (Blah) ctx.lookup("foo:blah");

Programmatic installation

You can re-set the default inital context factory builder using a standard naming API.

    NamingManager.setInitialContextFactoryBuilder(new WildFlyInitialContextFactoryBuilder());
    // later...
    InitialContext ctx = new InitialContext();
    Blah blah = (Blah) ctx.lookup("foo:blah");

Direct instantiation

You can bypass the standard discovery mechanism and go directly to the WildFlyInitialContext.

    InitialContext ctx = new WildFlyInitialContext();
    Blah blah = (Blah) ctx.lookup("foo:blah");

Remote naming

In order to associate an initial context with a specific (possibly remote) naming service, a naming provider URL is required. This is done in the standard way using the java.naming.provider.url property, found in the constant field javax.naming.Context#PROVIDER_URL.

    Hashtable<String, Object> env = new Hashtable<>();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");
    env.put(Context.PROVIDER_URL, "remote+https://nowhere.example.edu:8080");
    InitialContext ctx = new InitialContext(env);
    Blah blah = (Blah) ctx.lookup("foo:blah");

This property can also be specified as a system property.

Unlike the previous jboss-remote-naming project, the connection to the peer is not requested until an operation is performed on the connection, and all consumers of the same remote URL will share a connection. The connection lifecycle is independent of any Context instances which reference it.

Using the context

Multiple services can be looked up via the same context. To register providers, implement the org.wildfly.naming.client.NamingProvider interface and register the implementation using the approach described in the java.util.ServiceLoader documentation.

Maven

Find this artifact under the Maven coordinates org.wildfly:wildfly-naming-client.

wildfly-naming-client's People

Contributors

adamecp avatar bstansberry avatar chengfang avatar darranl avatar dependabot[bot] avatar dmlloyd avatar fjuma avatar fl4via avatar istudens avatar iweiss avatar jiriondrusek avatar jmesnil avatar kabir avatar n1hility avatar parsharma avatar rhusar avatar ropalka avatar stuartwdouglas avatar sudeshnas93 avatar tadamski avatar tomashofman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wildfly-naming-client's Issues

Wildfly JMS Client Configuration for JDK11

Hello,
I have a sample java program talking to redhat artemis via wildfly java library. https://github.com/wildfly/quickstart/blob/main/helloworld-jms/src/test/java/org/jboss/as/quickstarts/jms/HelloWorldJMSClientIT.java

If I run the above program in JDK8 then its working fine.
But if I run the same program in JDK11 then it fails while executing this line line:
context.lookup("jms/remoteConnectionFactory")

It fails with the error below:
Invalid URL Scheme "null "`

Looks like in JDK11, the following code creates an instance of ReparsedName with urlScheme being null.
https://github.com/wildfly/wildfly-naming-client/blob/main/src/main/java/org/wildfly/naming/client/WildFlyRootContext.java#L814

Can you help me fix the above problem? Do you have a working jms client example for JDK11 using this wildfly client library?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.