Examples of InitialContextFactory


Examples of javax.naming.spi.InitialContextFactory

   public InitialContextFactory createInitialContextFactory(Hashtable environment)
         throws NamingException
   {

      InitialContextFactory icf = null;

      if (environment != null)
      {
         String icfName = (String)environment.get("java.naming.factory.initial");
View Full Code Here

Examples of javax.naming.spi.InitialContextFactory

                }
                if (references != null) {
                    Context initialContext = null;
                    Arrays.sort(references, Utils.SERVICE_REFERENCE_COMPARATOR);
                    for (ServiceReference reference : references) {
                        InitialContextFactory factory = (InitialContextFactory) context.getService(reference);
                        try {
                            initialContext = factory.getInitialContext(environment);
                        } finally {
                            context.ungetService(reference);
                        }
                        if (initialContext != null) {
                            provider = new ContextProvider(reference, initialContext);
                            break;
                        }
                    }
                }
            }
        } else {
            // 1. lookup ContextFactory using the factory class
            String filter = "(&(objectClass=javax.naming.spi.InitialContextFactory)(objectClass="+ contextFactoryClass + "))";
            ServiceReference[] references = null;
            try {
                references = context.getServiceReferences(InitialContextFactory.class.getName(), filter);
            } catch (InvalidSyntaxException e) {
                NamingException ex = new NamingException("Bad filter: " + filter);
                ex.initCause(e);
                throw ex;
            }

            if (references != null && references.length > 0) {
                Context initialContext = null;
                Arrays.sort(references, Utils.SERVICE_REFERENCE_COMPARATOR);
                ServiceReference reference = references[0];
                InitialContextFactory factory = (InitialContextFactory) context.getService(reference);
                try {
                    initialContext = factory.getInitialContext(environment);
                } finally {
                    context.ungetService(reference);
                }
                if (initialContext != null) {
                    provider = new ContextProvider(reference, initialContext);                   
View Full Code Here

Examples of javax.naming.spi.InitialContextFactory

            throws NamingException {
        ContextProvider provider = null;
        try {
            ServiceReference[] refs = context.getAllServiceReferences(InitialContextFactoryBuilder.class.getName(), null);
            if (refs != null) {
                InitialContextFactory factory = null;
                Arrays.sort(refs, Utils.SERVICE_REFERENCE_COMPARATOR);
                for (ServiceReference ref : refs) {                   
                    InitialContextFactoryBuilder builder = (InitialContextFactoryBuilder) context.getService(ref);
                    try {
                        factory = builder.createInitialContextFactory(environment);
                    } catch (NamingException e) {
                        // TODO: log
                        // ignore
                    } finally {
                        context.ungetService(ref);
                    }
                    if (factory != null) {
                        provider = new ContextProvider(ref, factory.getInitialContext(environment));
                        break;
                    }
                }
            }
        } catch (InvalidSyntaxException e) {
View Full Code Here

Examples of javax.naming.spi.InitialContextFactory

            if (provider == null) {
                ServiceReference[] references = Activator.getInitialContextFactoryServices();
                if (references != null) {
                    Context initialContext = null;
                    for (ServiceReference reference : references) {
                        InitialContextFactory factory = (InitialContextFactory) context.getService(reference);
                        try {
                            initialContext = factory.getInitialContext(environment);
                            if (initialContext != null) {
                              provider = new SingleContextProvider(context, reference, initialContext);
                              break;
                          }
                        } finally {
                            if (provider == null) context.ungetService(reference);
                        }
                    }
                }
            }
        } else {
            ServiceReference ref = ServiceTrackerCustomizers.ICF_CACHE.find(contextFactoryClass);
           
            if (ref != null) {
              Context initialContext = null;
              InitialContextFactory factory = (InitialContextFactory) context.getService(ref);
              if (factory != null) {
                try {
                    initialContext = factory.getInitialContext(environment);
                    provider = new SingleContextProvider(context, ref, initialContext);
                } finally {
                    if (provider == null) context.ungetService(ref);
                }
              }
View Full Code Here

Examples of javax.naming.spi.InitialContextFactory

                                                                 Hashtable<?, ?> environment)
            throws NamingException {
        ContextProvider provider = null;
        ServiceReference[] refs = Activator.getInitialContextFactoryBuilderServices();
        if (refs != null) {
            InitialContextFactory factory = null;
            for (ServiceReference ref : refs) {                   
                InitialContextFactoryBuilder builder = (InitialContextFactoryBuilder) context.getService(ref);
                try {
                  factory = builder.createInitialContextFactory(environment);
                } catch (NamingException ne) {
                  // TODO: log
                  // ignore this, if the builder fails we want to move onto the next one
                }
               
                if (factory != null) {
                  try {
                    provider = new SingleContextProvider(context, ref, factory.getInitialContext(environment));
                  } finally {
                    if (provider == null) context.ungetService(ref); // we didn't get something back, so this was no good.
                  }
                  break;
                } else {
View Full Code Here

Examples of javax.naming.spi.InitialContextFactory

        bundle.start();
        BundleContext context = bundle.getBundleContext();
        ServiceReference ref = context.getServiceReference(InitialContextFactoryBuilder.class.getName());
        InitialContextFactoryBuilder builder = (InitialContextFactoryBuilder) context.getService(ref);

        InitialContextFactory factory = builder.createInitialContextFactory(null);
        Context iniCtx = factory.getInitialContext(null);

        Object lookup = iniCtx.lookup("java:jboss");
        assertNotNull("Lookup not null", lookup);
    }
View Full Code Here

Examples of javax.naming.spi.InitialContextFactory

    final String o = (String) hashtable.get("java.naming.factory.initial");
    if (StringUtils.isEmpty(o) == false &&
        DebugJndiContextFactory.class.getName().equals(o) == false)
    {
      final InitialContextFactory contextFactory =
          ObjectUtilities.loadAndInstantiate(o, DebugJndiContextFactory.class, InitialContextFactory.class);
      return contextFactory.getInitialContext(environment);
    }

    hashtable.put(JndiLoader.SIMPLE_DELIMITER, "/");
    try
    {
View Full Code Here

Examples of javax.naming.spi.InitialContextFactory

    }

    private Context getIntraVmContext(Hashtable env) throws javax.naming.NamingException {
        Context context = null;
        try {
            InitialContextFactory factory = null;
            ClassLoader cl = SystemInstance.get().getClassLoader();
            Class ivmFactoryClass = Class.forName("org.apache.openejb.core.ivm.naming.InitContextFactory", true, cl);

            factory = (InitialContextFactory) ivmFactoryClass.newInstance();
            context = factory.getInitialContext(env);
        } catch (Exception e) {
            throw (NamingException)new javax.naming.NamingException("Cannot instantiate an IntraVM InitialContext. Exception: "
                    + e.getClass().getName() + " " + e.getMessage()).initCause(e);
        }
View Full Code Here

Examples of javax.naming.spi.InitialContextFactory

            typeDefaults.put(ft, ft.wrap(defaultFactory));
        }
       
        this.pretendNoFactoryBuilder = pretendNoFactoryBuilder;
   
        this.defaultFactory = new InitialContextFactory() {
            public Context getInitialContext(Hashtable<?, ?> environment) throws NamingException {
                return typeDefaults.get(FactoryType.detect(environment, pretendNoFactoryBuilder)).getInitialContext(
                    environment);
            }
        };
View Full Code Here

Examples of javax.naming.spi.InitialContextFactory

            return defaultFactory;
        }
        final ClassLoader classLoader = getContextClassLoader();
        try {
            final Class<?> factoryClass = Class.forName(factoryClassName, true, classLoader);
            InitialContextFactory configuredFactory = (InitialContextFactory) factoryClass.newInstance();           
            return FactoryType.detect(environment, pretendNoFactoryBuilder).wrap(configuredFactory);
        } catch (Exception e) {
            NamingException ne = new NamingException("Failed instantiate InitialContextFactory "
                + factoryClassName
                + " from classloader "
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.