Package org.jboss.fresh.registry

Examples of org.jboss.fresh.registry.RegistryContext


        }
        con.setAutoCommit(false);
      }
    } else {
      if (dts == null) {
        RegistryContext ctx = new RegistryContext();
        dts = (DataSource) ctx.lookup(ds);
      }

      con = dts.getConnection();
      log.info("Got connection from pool: " + con + " (autocommit:" + con.getAutoCommit() + ')');
      con.setAutoCommit(false);
View Full Code Here


      String tmp = params[i];

      // take parameter 1
      // look up the name through InitialContext
      RegistryContext ctx = new RegistryContext();
      Object obj = null;
      try {
        obj = (Context) ctx.lookup(tmp);
      } catch (Exception ex) {
        if (canThrowEx()) {
          throw new Exception("No object found in JNDI for name: " + tmp);
        } else {
          err.println("No object found in JNDI for name: " + tmp);
          log.debug("CtxDelegateExe done.");
          return;
        }
      }

      // See if what you got is instance of Context

      if (!(obj instanceof Context)) {
        if (canThrowEx()) {
          throw new Exception("Object found in JNDI for name: " + tmp + " is not org.jboss.fresh.ctx.Context type.");
        } else {
          err.println("Object found in JNDI for name: " + tmp + " is not org.jboss.fresh.ctx.Context type.");
          log.debug("CtxDelegateExe done.");
          return;
        }
      }

      Context ctx0 = (Context) obj;
      // now shell.getContext()
      if(log.isDebugEnabled()) {
        log.debug("shell: " + shell + ", ctx: "  + shell.getContext());
      }
      shell.getContext().registerDelegate(ctx0);
      shell.getContext().put("AppContext", ctx0);

      Context gctx = null;
      try {
        tmp = "java:/FRESH/GlobalContext";
        gctx = (Context) ctx.lookup(tmp);
      } catch (Exception ex) {
        if (canThrowEx()) {
          throw new Exception("No object found in JNDI for name: " + tmp);
        } else {
          err.println("No object found in JNDI for name: " + tmp);
View Full Code Here

        return null;

    }

    private void bind() throws NamingException {
        Context ctx = new RegistryContext();
        String name = getJNDIName();
        if (name == null)
            return;

        log.info("name: "+name);
        // if (!name.startsWith("java:/")) {
        //    name = "java:/" + name;
        // }
 
        m_bindName = name;

    // Ah ! This class isn't serializable, so we use a helper class
    // Make this work - oneliner for binding
    //ctx.bind(m_bindName, getBindInstance());

    Name n = ctx.getNameParser("").parse(m_bindName);
    while (n.size() > 1) {
      String ctxName = n.get(0);
      try {
        ctx = (Context) ctx.lookup(ctxName);
      } catch (NameNotFoundException e) {
        ctx = ctx.createSubcontext(ctxName);
      }
      n = n.getSuffix(1);
    }

    Object bindInstance = getBindInstance();
    ctx.bind(n.get(0), bindInstance);

    log.info(getName() + ": '" + getJNDIName() + "' bound to '" + m_bindName + "' in registry");
   
    icBind(bindInstance);
    }
View Full Code Here

    log.info(getName() + ": '" + getJNDIName() + "' bound to '" + name + "' in JNDI");   
  }

  private void unbind() throws NamingException {
        if (m_bindName != null) {
            new RegistryContext().unbind(m_bindName);
            log.info(getName() + ": '" + getJNDIName() + "' removed from registry");
       
        }
       
        icUnbind();       
View Full Code Here

        try {

            Object o = map.get(key);
            if (o == null) return null;

            RegistryContext ctx = new RegistryContext();
            return ctx.lookup((String) o);

        } catch (Exception ex) {
            throw new RuntimeException(ex.toString(), ex);
        }
    }
View Full Code Here

        Shell shell = null;
        RemoteShell rshell = null;
        ShellOutputStream sos = null;
        OutputStreamWriter osw = null;
        try {
            ctx = new RegistryContext();

            try {
                SystemShell sysshell = (SystemShell) ctx.lookup("java:/FRESH/SystemShell");
                log.log(TRACE, "Retrieved SystemShell from RegistryContext: 'SystemShell'.");
                shell = sysshell.startSession(null, false);
View Full Code Here

            out = new PrintWriter(new OutputStreamWriter(bos));

          try {

                if (eUseLocal) {
                    RegistryContext ctx = new RegistryContext();
                    SystemShell sysshell = (SystemShell) ctx.lookup(eSvcname);
                    Shell shell = sysshell.startSession(null, false);

                    try {
                        // now line by line
                        // And put all exceptions to log too.
                        String cmd = in.readLine();
                        while (cmd != null) {
                            cmd = cmd.trim();
                          if(out!=null) {
                              out.println(getTime() + " Executing: " + cmd);
                              out.flush();
                            }
                           
                          if(! "".equals(cmd)) {
                              ProcessInfo pinf = shell.execute(cmd, true);
                                                           
                              BufferedInputStream bin = new BufferedInputStream(new ShellConsoleInputStream(new ShellObjectReader(shell, pinf.procid)));
                              try {
                                  IOUtils.copy(bin, bos, 50000);
                              } catch (Exception ex) {
                                  try {
                                      if(out != null) {
                                        out.println(getTime() + " Exception has occured:");
                                        ex.printStackTrace(out);
                                      }
                                  } catch (Exception e) {
                                      e.printStackTrace();
                                  }
 
                                  if (stopOnError) {
                                      throw ex;
                                  }
                              }
                                                           
                          }
                            cmd = in.readLine();
                        }
                    } finally {
                        try {
                            shell.close();
                        } catch (ShellException e) {
                        }
                    }
                } else {
                    // we get RemoteShell
                    InitialContext ctx = new InitialContext();
                    RemoteShellHome home = (RemoteShellHome) ctx.lookup(eSvcname);
                    RemoteShell shell = home.create();

                    try {
                        // now line by line
                        // And put all exceptions to log too.
View Full Code Here

    }

    public void doStart() throws Exception {
        super.doStart();
        if (props != null) {
            RegistryContext ctx = new RegistryContext();
            Set set = props.entrySet();
            Iterator it = set.iterator();
            while (it.hasNext()) {
                Map.Entry ent = (Map.Entry) it.next();
                String path = (String) ent.getKey();
                String jndi = (String) ent.getValue();

                VFS mvfs = (VFS) ctx.lookup(jndi);
                vfs.mount(path, mvfs);
            }
        }
    }
View Full Code Here


    EventCentral ec = null;

    if (name != null) {
      RegistryContext ctx = new RegistryContext();
      try {
         ec = (EventCentral) ctx.lookup(name);
      } catch(ClassCastException ex) {
        error("Object bound in registry under " + name + " is not a valid EventCentral object: " + ctx.lookup(name));
        return;
      } catch(NamingException ex) {
        log.error("Failed to retrieve EventCentral: ", ex);
        error("Failed to find EventCentral with registry name: " + name);
        return;
      }
    } else {
      Context ctx = getShell().getContext();
      ec = (EventCentral) ctx.get("EventCentral");
    }

    if(ec == null) {
      error("Failed to locate EventCentral (make sure you specify EventCentral lookup name, or make sure instance is available in shell context under 'EventCentral')");
      return;
View Full Code Here

            h.add(hitem);
        }

        // would be nice to have a wrapper that returns null and throws no exceptions
        try {
            actx = (Context) new RegistryContext().lookup("java:/FRESH/GlobalContext");
        } catch(Exception ex) {
        }

        if(actx == null) {
            log.debug("GlobalContext not available");
View Full Code Here

TOP

Related Classes of org.jboss.fresh.registry.RegistryContext

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.