get Entity Service - Java JNDI

Java examples for JNDI:Context

Description

get Entity Service

Demo Code


import javax.naming.InitialContext;
import javax.naming.NamingException;

public class Main{

    public static EntityService getEntityService() {
        InitialContext initialContext;
        try {//w ww.ja va  2s  .c o m
            initialContext = new InitialContext();
            EntityService es = (EntityService) initialContext
                    .lookup("java:comp/env/EntityService");
            initialContext.close();
            return es;
        } catch (NamingException e) {
            System.err
                    .println("Naming Exception in AccessHelper.getEntityService");
            e.printStackTrace();
            return null;
        }
    }
}

Related Tutorials