Package org.glassfish.hk2.api

Examples of org.glassfish.hk2.api.ServiceLocator


    @Override
    public ServiceLocator create(String name, ServiceLocator parent,
            ServiceLocatorGenerator generator) {
        synchronized (lock) {
            ServiceLocator retVal;

            if (name == null) {
                name = GENERATED_NAME_PREFIX + name_count++;
                return internalCreate(name, parent, generator);
            }
View Full Code Here


     * @throws MultiException if any error was encountered while binding services
     */
    public static ServiceLocator bind(String name, Binder... binders) {
        ServiceLocatorFactory factory = ServiceLocatorFactory.getInstance();

        ServiceLocator locator = factory.create(name);
        bind(locator, binders);

        return locator;
    }
View Full Code Here

     * with {@link ServiceLocatorFactory#find(String)}.
     * @return A service locator that has been populated with services
     * @throws MultiException If there was a failure when populating or creating the ServiceLocator
     */
    public static ServiceLocator createAndPopulateServiceLocator(String name) throws MultiException {
        ServiceLocator retVal = ServiceLocatorFactory.getInstance().create(name);
       
        DynamicConfigurationService dcs = retVal.getService(DynamicConfigurationService.class);
        Populator populator = dcs.getPopulator();
       
        try {
            populator.populate();
        }
View Full Code Here

  // We need to get the ServletContext to find the Habitat
  ServletContext servletCtx = (ServletContext)
      (ctx.getExternalContext()).getContext();

  // Get the Habitat from the ServletContext
  ServiceLocator habitat = (ServiceLocator) servletCtx.getAttribute(
      org.glassfish.admingui.common.plugin.ConsoleClassLoader.HABITAT_ATTRIBUTE);

//  System.out.println("Habitat:" + habitat);

  return habitat.getService(ConsolePluginService.class);
    }
View Full Code Here

            markAsShared();

            final State runtimeCfgState = this.copy();
            runtimeCfgState.markAsShared();

            final ServiceLocator locator = Injections.createLocator(new ClientBinder(runtimeCfgState.getProperties()));
            locator.setDefaultClassAnalyzerName(JerseyClassAnalyzer.NAME);

            // AutoDiscoverable.
            if (!CommonProperties.getValue(runtimeCfgState.getProperties(), RuntimeType.CLIENT,
                    CommonProperties.FEATURE_AUTO_DISCOVERY_DISABLE, Boolean.FALSE, Boolean.class)) {
                runtimeCfgState.configureAutoDiscoverableProviders(locator);
            } else {
                runtimeCfgState.configureForcedAutoDiscoverableProviders(locator);
            }

            // Configure binders and features.
            runtimeCfgState.configureMetaProviders(locator);

            // Bind configuration.
            final AbstractBinder configBinder = new AbstractBinder() {
                @Override
                protected void configure() {
                    bind(runtimeCfgState).to(Configuration.class);
                }
            };
            final DynamicConfiguration dc = Injections.getConfiguration(locator);
            configBinder.bind(dc);
            dc.commit();

            // Bind providers.
            ProviderBinder.bindProviders(runtimeCfgState.getComponentBag(), RuntimeType.CLIENT, null, locator);

            final ClientConfig configuration = new ClientConfig(runtimeCfgState);
            final Connector connector = connectorProvider.getConnector(client, configuration);
            final ClientRuntime crt = new ClientRuntime(configuration, connector, locator);
            client.addListener(new JerseyClient.LifecycleListener() {
                @Override
                public void onClose() {
                    try {
                        crt.close();
                    } finally {
                        ServiceLocatorFactory.getInstance().destroy(locator.getName());
                    }
                }
            });

            return crt;
View Full Code Here

  // Get the ServletContext
  ServletContext servletCtx = (ServletContext)
      (FacesContext.getCurrentInstance().getExternalContext()).getContext();

  // Get the Habitat from the ServletContext
  ServiceLocator habitat = (ServiceLocator) servletCtx.getAttribute(HABITAT_ATTRIBUTE);

  // Use the Habitat to find the ConsolePluginService and return the
  // correct ClassLoader for the requested module (or null)
  return habitat.<ConsolePluginService>getService(ConsolePluginService.class).
      getModuleClassLoader(moduleName);
    }
View Full Code Here

    private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
        stream.defaultReadObject();

        //Initialize the transients that were passed at ctor.
        ServiceLocator defaultServiceLocator = Globals.getDefaultHabitat();
        invMgr        = defaultServiceLocator.getService(InvocationManager.class);
        compEnvMgr    = defaultServiceLocator.getService(ComponentEnvManager.class);
    }
View Full Code Here

    private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
        stream.defaultReadObject();

        //Initialize the transients that were passed at ctor.
        ServiceLocator defaultServiceLocator = Globals.getDefaultHabitat();
        txManager     = defaultServiceLocator.getService(TransactionManager.class);
        invMgr        = defaultServiceLocator.getService(InvocationManager.class);
        compEnvMgr    = defaultServiceLocator.getService(ComponentEnvManager.class);
        callFlowAgent = defaultServiceLocator.getService(CallFlowAgent.class);
    }
View Full Code Here

    public static void initialize(Client client) {
        if (client == null) {
            client = getJerseyClient();
        }
        try {
            ServiceLocator habitat = SecurityServicesUtil.getInstance().getHabitat();
            SecureAdmin secureAdmin = habitat.getService(SecureAdmin.class);
            client.configuration().setProperty(ClientProperties.SSL_CONFIG, new SslConfig(new BasicHostnameVerifier(),
                                                                                          habitat.<SSLUtils>getService(SSLUtils.class).getAdminSSLContext(SecureAdmin.Util.DASAlias(secureAdmin), null)));
            client.configuration().register(CsrfProtectionFilter.class);

        } catch (Exception ex) {
            Throwable cause = ex;
            int lcv = 0;
View Full Code Here

    }

    public static ServiceLocator getHabitat() {
        ServletContext servletCtx = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();
        // Get the Habitat from the ServletContext
        ServiceLocator habitat = (ServiceLocator) servletCtx.getAttribute(
                org.glassfish.admingui.common.plugin.ConsoleClassLoader.HABITAT_ATTRIBUTE);
        return habitat;
    }
View Full Code Here

TOP

Related Classes of org.glassfish.hk2.api.ServiceLocator

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.