Package org.glassfish.hk2.api

Examples of org.glassfish.hk2.api.ServiceLocator


                }
            };

            // Install the all-trusting trust manager
            SSLContext sc = SSLContext.getInstance(TLS);
            ServiceLocator habitat = Globals.getDefaultHabitat();
            SSLUtils sslUtils = habitat.getService(SSLUtils.class);
            sc.init(sslUtils.getKeyManagers(), trustAllCerts, new java.security.SecureRandom());

            //---------------------------------
            url = new URL(HTTPS_PROTOCOL, _lbHost, Integer.parseInt(_lbPort), contextRoot);
            if (_lbProxyHost != null && _lbProxyPort != null) {
View Full Code Here


        ctx.setLogger(LogDomains.getLogger(
                DomainInitializer.class, LogDomains.SERVER_LOGGER));

        // now for every such Inhabitant, fetch the actual initial config and
        // insert it into the module that initial config was targeted for.
        ServiceLocator habitat = glassfish.getService(ServiceLocator.class);
        Collection<DomainInitializer> inits =
                habitat.getAllServices(DomainInitializer.class);
        if (inits.isEmpty()) {
            logger.info(strings.get("NoCustomization"));
        }
        for (DomainInitializer inhabitant : habitat.<DomainInitializer>getAllServices(
                DomainInitializer.class)) {
            logger.info(strings.get("InvokeInitializer",
                    inhabitant.getClass()));
            Container newContainerConfig = inhabitant.getInitialConfig(ctx);
            try {
View Full Code Here

  throws Exception
    {
        if (initialized) {
            return;
        }
        ServiceLocator habitat = Globals.getDefaultHabitat();
        SSLUtils sslUtils = habitat.getService(SSLUtils.class);

        keyManagers = sslUtils.getKeyManagers();
        trustManagers = sslUtils.getTrustManagers();
 
        // Creating a default SSLContext and HttpsURLConnection for clients
View Full Code Here

        }
        else {
            loaderName = loader.toString();
        }
       
        ServiceLocator retVal = FACTORY.find(loaderName);
        if (retVal != null) return retVal;
       
        return FACTORY.create(loaderName);
    }
View Full Code Here

  /* (non-Javadoc)
   * @see org.glassfish.hk2.api.ServiceLocatorFactory#destroy(java.lang.String)
   */
  @Override
  public void destroy(String name) {
      ServiceLocator killMe = null;
   
      synchronized (lock) {
          killMe = serviceLocators.remove(name);
         
          if (killMe != null) {
              for (ServiceLocatorListener listener : listeners) {
                  try {
                      listener.listenerDestroyed(killMe);
                  }
                  catch (Throwable th) {
                      logger.log(Level.FINE, "Exception thrown from listenerDestroyed method of " + listener, th);
                  }
              }
          }
      }
   
      if (killMe != null) {
          killMe.shutdown();
      }
  }
View Full Code Here

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

            if (name == null) {
                name = getGeneratedName();
                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

  /* (non-Javadoc)
   * @see org.glassfish.hk2.api.ServiceLocatorFactory#destroy(java.lang.String)
   */
  @Override
  public void destroy(String name) {
      ServiceLocator killMe = null;
   
      synchronized (lock) {
          killMe = serviceLocators.remove(name);
         
          if (killMe != null) {
              for (ServiceLocatorListener listener : listeners) {
                  try {
                      listener.listenerDestroyed(killMe);
                  }
                  catch (Throwable th) {
                      logger.log(Level.FINE, "Exception thrown from listenerDestroyed method of " + listener, th);
                  }
              }
          }
      }
   
      if (killMe != null) {
          killMe.shutdown();
      }
  }
View Full Code Here

            if (loginErrorPage == null) {
                throw new AuthException("'loginErrorPage' "
                        + "must be supplied as a property in the provider-config "
                        + "in the domain.xml file!");
            }
            ServiceLocator habitat = SecurityServicesUtil.getInstance().getHabitat();
            Domain domain = habitat.getService(Domain.class);
            NetworkListener adminListener = domain.getServerNamed("server").getConfig().getNetworkConfig().getNetworkListener("admin-listener");

            if (restURL.contains(TOKEN_ADMIN_LISTENER_PORT)) {
                restURL = restURL.replace(TOKEN_ADMIN_LISTENER_PORT, adminListener.getPort());
            }

      String host = adminListener.getAddress();
      if (! ("localhost".equals(host) || "0.0.0.0".equals(host))){
                restURL = restURL.replace("localhost", adminListener.getAddress());
            }

            //If secure admin is enabled, we need to ensure using https
            SecureAdmin secureAdmin = habitat.getService(SecureAdmin.class);
            if (restURL.startsWith("http:") && (SecureAdmin.Util.isEnabled(secureAdmin))) {
                restURL = restURL.replace("http:", "https:");
            }
        }
    }
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.