示例#1
0
 protected URI launchDetachedCommand(String command, ParameterMap parameters) {
   CommandRunner cr = Globals.getDefaultHabitat().getService(CommandRunner.class);
   final RestActionReporter ar = new RestActionReporter();
   final CommandRunner.CommandInvocation commandInvocation =
       cr.getCommandInvocation(command, ar, getSubject()).parameters(parameters);
   final String jobId = DetachedCommandHelper.invokeAsync(commandInvocation);
   return getUri("jobs/id/" + jobId);
 }
示例#2
0
 static {
   try {
     _iiopUtils = Globals.getDefaultHabitat().getService(IIOPUtils.class);
     Collection<org.glassfish.grizzly.config.dom.ThreadPool> tpCol =
         _iiopUtils.getAllThreadPools();
     org.glassfish.grizzly.config.dom.ThreadPool[] allThreadPools =
         tpCol.toArray(new org.glassfish.grizzly.config.dom.ThreadPool[tpCol.size()]);
     for (int i = 0; i < allThreadPools.length; i++) {
       createThreadPools(allThreadPools[i], i);
     }
     defaultID = (String) indexToIdTable.get(Integer.valueOf(0));
   } catch (NullPointerException npe) {
     _logger.log(Level.FINE, "Server Context is NULL. Ignoring and proceeding.");
   }
 }
  private String getApplicationName(String path) {
    Habitat habitat = Globals.getDefaultHabitat();

    Domain domain = habitat.getInhabitantByType(Domain.class).get();

    List<Application> applicationList = domain.getApplications().getApplications();

    // looks like path always ends with "/" .. but just to be sure..
    for (Application app : applicationList) {
      if (path.startsWith(app.getContextRoot() + "/") || path.equals(app.getContextRoot()))
        return app.getName();
    }

    return null;
  }
示例#4
0
  /**
   * Lookup an object in the serial context.
   *
   * @return the object that is being looked up.
   * @throws NamingException if there is a naming exception.
   */
  @Override
  public Object lookup(String name) throws NamingException {
    if (_logger.isLoggable(Level.FINE))
      _logger.log(
          Level.FINE,
          "In javaURLContext.lookup, name = " + name + " serialcontext..." + serialContext);

    if (name.equals("")) {
      /**
       * javadocs for Context.lookup: If name is empty, returns a new instance of this context
       * (which represents the same naming context as this context, but its environment may be
       * modified independently and it may be accessed concurrently).
       */
      return new JavaURLContext(myName, myEnv);
    }

    String fullName = name;
    if (!myName.equals("")) {
      if (myName.equals("java:")) fullName = myName + name;
      else fullName = myName + "/" + name;
    }

    try {
      Object obj = null;
      // If we know for sure it's an entry within an environment namespace
      if (fullName.startsWith("java:comp/env/")
          || fullName.startsWith("java:module/env/")
          || fullName.startsWith("java:app/env/")) {
        // refers to a dependency defined by the application
        obj = namingManager.lookup(fullName, serialContext);
      } else {
        // It's either an application-defined dependency in a java:
        // namespace or a special EE platform object.
        // Check for EE platform objects first to prevent overriding.
        obj = NamedNamingObjectManager.tryNamedProxies(name);
        if (obj == null) {
          // try GlassfishNamingManager
          obj = namingManager.lookup(fullName, serialContext);
        }
      }

      if (obj == null) {
        throw new NamingException("No object found for " + name);
      }

      return obj;
    } catch (NamingException ex) {

      Habitat habitat = Globals.getDefaultHabitat();
      ProcessEnvironment processEnv = habitat.getComponent(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 = habitat.getByContract(ComponentNamingUtil.class);
          String internalGlobalJavaAppName =
              compNamingUtil.composeInternalGlobalJavaAppName(appName, fullName);

          obj = ic.lookup(internalGlobalJavaAppName);
        }

        if (obj == null) {
          throw new NamingException("No object found for " + name);
        }

        return obj;
      }

      throw ex;
    } catch (Exception ex) {
      throw (NamingException)
          (new NameNotFoundException("No object bound for " + fullName)).initCause(ex);
    }
  }
 public WebServiceContextImpl() {
   if (Globals.getDefaultHabitat() != null) {
     secServ = Globals.get(org.glassfish.webservices.SecurityService.class);
   }
 }
 /**
  * Do all ProtocolManager access lazily and only request orb if it has already been initialized so
  * that code doesn't make the assumption that an orb is available in this runtime.
  */
 private ProtocolManager getProtocolManager() {
   GlassFishORBHelper orbHelper =
       Globals.getDefaultHabitat().getComponent(GlassFishORBHelper.class);
   return orbHelper.isORBInitialized() ? orbHelper.getProtocolManager() : null;
 }