Package org.glassfish.hk2.utilities

Examples of org.glassfish.hk2.utilities.BuilderHelper


    private static synchronized ServiceLocator getManHabitat() {
        if (manServiceLocator != null)
            return manServiceLocator;
       
        ModulesRegistry registry = new StaticModulesRegistry(getModuleClassLoader());
        ServiceLocator serviceLocator = registry.createServiceLocator("default");
        manServiceLocator = serviceLocator;
        return manServiceLocator;
    }
View Full Code Here


            final StartupContext startupContext = new StartupContext(gfProps.getProperties());
           
            ModulesRegistry modulesRegistry = SingleHK2Factory.getInstance().createModulesRegistry();

            ServiceLocator serviceLocator = main.createServiceLocator(modulesRegistry, startupContext, Arrays.asList((PopulatorPostProcessor)new EmbeddedInhabitantsParser(), new ContextDuplicatePostProcessor()), null);

            final ModuleStartup gfKernel = main.findStartupService(modulesRegistry, serviceLocator, null, startupContext);
            // create a new GlassFish instance
            GlassFishImpl gfImpl = new GlassFishImpl(gfKernel, serviceLocator, gfProps.getProperties()) {
                @Override
View Full Code Here

            }

            return obj;
        } catch (NamingException ex) {

            ServiceLocator services = Globals.getDefaultHabitat();
            ProcessEnvironment processEnv = services.getService(ProcessEnvironment.class);
            if( fullName.startsWith("java:app/") &&
                processEnv.getProcessType() == ProcessType.ACC ) {

                // This could either be an attempt by an app client to access a portable
                // remote session bean JNDI name via the java:app namespace or a lookup of
                // an application-defined java:app environment dependency.  Try them in
                // that order.

                Context ic = namingManager.getInitialContext();
                String appName = (String) namingManager.getInitialContext().lookup("java:app/AppName");

                Object obj = null;

                if( !fullName.startsWith("java:app/env/")) {
                    try {

                        // Translate the java:app name into the equivalent java:global name so that
                        // the lookup will be resolved by the server.
                        String newPrefix = "java:global/" + appName + "/";

                        int javaAppLength = "java:app/".length();
                        String globalLookup = newPrefix + fullName.substring(javaAppLength);

                        obj = ic.lookup(globalLookup);

                    } catch(NamingException javaappenvne) {
                        logger.log(Level.FINE, "Trying global version of java:app ejb lookup", javaappenvne);
                    }
                }

                if( obj == null ) {
                   ComponentNamingUtil compNamingUtil = services.getService(ComponentNamingUtil.class);
                   String internalGlobalJavaAppName =
                    compNamingUtil.composeInternalGlobalJavaAppName(appName, fullName);

                    obj = ic.lookup(internalGlobalJavaAppName);
                }
View Full Code Here

    public static boolean isImplicitBeanDiscoveryEnabled() {
        boolean result = false;

        // Check the "global" configuration
        ServiceLocator serviceLocator = Globals.getDefaultHabitat();
        if (serviceLocator != null) {
            Config config = serviceLocator.getService(Config.class, ServerEnvironment.DEFAULT_INSTANCE_NAME);
            if (config != null) {
                result = Boolean.valueOf(config.getExtensionByType(CDIService.class).getEnableImplicitCdi());
            }
        }
View Full Code Here

            final ServiceTracker hk2Tracker = new ServiceTracker(getBundleContext(), Main.class.getName(), null);
            hk2Tracker.open();
            final Main main = (Main) hk2Tracker.waitForService(0);
            hk2Tracker.close();
            final ModulesRegistry mr = ModulesRegistry.class.cast(getBundleContext().getService(getBundleContext().getServiceReference(ModulesRegistry.class.getName())));
            ServiceLocator serviceLocator = main.createServiceLocator(mr, startupContext, null, null);
            final ModuleStartup gfKernel = main.findStartupService(mr, serviceLocator, null, startupContext);
            GlassFish glassFish = createGlassFish(gfKernel, serviceLocator, gfProps.getProperties());
            gfs.add(glassFish);
            return glassFish;
        } catch (BootException ex) {
View Full Code Here

        if (ServletContext.class.isAssignableFrom( spiType)) {
            return (T)servletContext;
        }
       
        if (ServerPipelineHook.class.isAssignableFrom(spiType)){
            ServiceLocator h = Globals.getDefaultHabitat();
            ServerPipeCreator s = h.getService(ServerPipeCreator.class);
            s.init(endpoint);
            return((T)s);
        }

        if (ResourceInjector.class.isAssignableFrom(spiType)) {
View Full Code Here

        if (rc.skipDuringCreation() && dom.getKey() == null) {
            return true; //During creation the coresponding DOM is not fully loaded.
        }
        Collection<RemoteKeyInfo> remoteKeys = findRemoteKeys(config);
        if (remoteKeys != null && !remoteKeys.isEmpty()) {
            ServiceLocator habitat = dom.getHabitat();
            boolean result = true;
            boolean disableGlobalMessage = true;
            for (RemoteKeyInfo remoteKeyInfo : remoteKeys) {
                if (remoteKeyInfo.method.getParameterTypes().length > 0) {
                    throw new UnexpectedTypeException(localStrings.getLocalString("referenceValidator.not.getter",
                            "The RemoteKey annotation must be on a getter method."));
                }
                try {
                    Object value = remoteKeyInfo.method.invoke(config);
                    if (value instanceof String) {
                        String key = (String) value;
                        ConfigBeanProxy component = habitat.getService(remoteKeyInfo.annotation.type(), key);
                        if (component == null) {
                            result = false;
                            if (remoteKeyInfo.annotation.message().isEmpty()) {
                                disableGlobalMessage = false;
                            } else {
View Full Code Here

        if (app == null) {
            return true;
        }
        Dom dom = Dom.unwrap(app);

        ServiceLocator locator = dom.getHabitat();
        if (locator == null) return true;

        ConfigBeansUtilities cbu = locator.getService(ConfigBeansUtilities.class);
        if (cbu == null) return true;

        Domain domain = cbu.getDomain();
        String appName = app.getName();
View Full Code Here

    Domain domain = null;

    @Override
    public void initialize(NotDuplicateTargetName constraintAnnotation) {
      ServiceLocator locator = ServiceLocatorFactory.getInstance().find("default");
      if (locator == null) return;
     
      ConfigBeansUtilities cbu = locator.getService(ConfigBeansUtilities.class);
      if (cbu == null) return;
     
        domain = cbu.getDomain();
    }
View Full Code Here

        }
        return sb.toString();
    }

    public static Map<String, String> getCurrentValues(String basePath) {
        ServiceLocator serviceLocator = Globals.getDefaultBaseServiceLocator();
        return getCurrentValues(basePath, serviceLocator);
    }
View Full Code Here

TOP

Related Classes of org.glassfish.hk2.utilities.BuilderHelper

Copyright © 2018 www.massapicom. 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.