javax.naming.Context#rebind ( )源码实例Demo

下面列出了javax.naming.Context#rebind ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: tomee   文件: Assembler.java
public void bindGlobals(final Map<String, Object> bindings) throws NamingException {
    final Context containerSystemContext = containerSystem.getJNDIContext();
    for (final Entry<String, Object> value : bindings.entrySet()) {
        final String path = value.getKey();
        // keep only global bindings
        if (path.startsWith("module/") || path.startsWith("app/") || path.startsWith("comp/") || path.equalsIgnoreCase("global/dummy")) {
            continue;
        }

        // a bit weird but just to be consistent if user doesn't lookup directly the resource
        final Context lastContext = Contexts.createSubcontexts(containerSystemContext, path);
        try {
            lastContext.rebind(path.substring(path.lastIndexOf('/') + 1, path.length()), value.getValue());
        } catch (final NameAlreadyBoundException nabe) {
            nabe.printStackTrace();
        }
        containerSystemContext.rebind(path, value.getValue());
    }
}
 
源代码2 项目: rxjava-jdbc   文件: DatabaseViaDataSourceTest.java
private static DataSource initDataSource() {
    JdbcDataSource dataSource = new JdbcDataSource();
    String dbUrl = DatabaseCreator.nextUrl();
    dataSource.setURL(dbUrl);

    String jndiName = "jdbc/RxDS";

    try {
        Context context = new InitialContext();
        context.rebind(jndiName, dataSource);
    } catch (NamingException e) {
        throw new RuntimeException(e);
    }

    return dataSource;
}
 
源代码3 项目: oodt   文件: ExecServer.java
public void run() {
	while (shouldKeepBinding()) {
	  try {
		Context objectContext = configuration.getObjectContext();
		objectContext.rebind(name, server.getServant());
		objectContext.close();
	  } catch (Exception ex) {
		System.err.println("Exception binding at " + new Date() + "; will keep trying...");
		ex.printStackTrace();
	  } finally {
		try {
		  Thread.sleep(REBIND_PERIOD);
		} catch (InterruptedException ignore) {
		}
	  }
	}
}
 
源代码4 项目: openjdk-jdk9   文件: HelloServer.java
public static void main(String[] args) {
    int retryCount = 0;
    while (retryCount < MAX_RETRY) {
        try {
            // Step 1: Instantiate the Hello servant
            HelloImpl helloRef = new HelloImpl();

            // Step 2: Publish the reference in the Naming Service
            // using JNDI API
            Context initialNamingContext = new InitialContext();
            initialNamingContext.rebind("HelloService", helloRef);

            System.out.println("Hello Server: Ready...");
            break;
        } catch (Exception e) {
            System.out.println("Server initialization problem: " + e);
            e.printStackTrace();
            retryCount++;
            try {
                Thread.sleep(ONE_SECOND);
            } catch (InterruptedException e1) {
                e1.printStackTrace();
            }
        }
    }
}
 
源代码5 项目: JVoiceXML   文件: JVoiceXmlJndiSupport.java
/**
 * Binds the given stub and skeleton.
 *
 * <p>
 * Both have to be exported. The skeleton has to be accessed from the
 * stub via RMI and the stub has to be exported to be accessible via
 * JNDI.
 * </p>
 *
 * @param context The context to bind skeleton and stub.
 * @param skeleton The skeleton to bind.
 * @param stub The stub to bind.
 */
static void bind(final Context context, final Skeleton skeleton,
                 final Stub stub) {
    final String skeletonName;
    try {
        skeletonName = skeleton.getSkeletonName();
    } catch (RemoteException re) {
        LOGGER.error("error retrieving the skeleton name", re);
        return;
    }

    final String stubName = stub.getStubName();
    try {
        context.rebind(skeletonName, skeleton);
        context.rebind(stubName, stub);
    } catch (javax.naming.NamingException ne) {
        LOGGER.error("naming exception while exporting '" + skeletonName
                     + "'", ne);
        return;
    }

    LOGGER.info("bound '" + stubName + "' to '"
            + stub.getClass().getName() + "'");
}
 
源代码6 项目: activemq-artemis   文件: JndiBindingRegistry.java
private boolean bindToJndi(final String jndiName, final Object objectToBind) throws NamingException {
   if (context != null) {
      String parentContext;
      String jndiNameInContext;
      int sepIndex = jndiName.lastIndexOf('/');
      if (sepIndex == -1) {
         parentContext = "";
      } else {
         parentContext = jndiName.substring(0, sepIndex);
      }
      jndiNameInContext = jndiName.substring(sepIndex + 1);
      try {
         context.lookup(jndiName);

         //JMSServerManagerImpl.log.warn("Binding for " + jndiName + " already exists");
         return false;
      } catch (Throwable e) {
         // OK
      }

      Context c = JNDIUtil.createContext(context, parentContext);

      c.rebind(jndiNameInContext, objectToBind);
   }
   return true;
}
 
源代码7 项目: dragonwell8_jdk   文件: HelloServer.java
public static void main(String[] args) {
    int retryCount = 0;
    while (retryCount < MAX_RETRY) {
        try {
            //HelloServer.set("SETTING TEST ITL");
            // Step 1: Instantiate the Hello servant
            HelloImpl helloRef = new HelloImpl();

            // Step 2: Publish the reference in the Naming Service
            // using JNDI API
            Context initialNamingContext = new InitialContext();
            initialNamingContext.rebind("HelloService", helloRef);

            System.out.println("Hello Server: Ready...");
            break;
        } catch (Exception e) {
            System.out.println("Server initialization problem: " + e);
            e.printStackTrace();
            retryCount++;
            try {
                Thread.sleep(ONE_SECOND);
            } catch (InterruptedException e1) {
                e1.printStackTrace();
            }
        }
    }
}
 
源代码8 项目: TencentKona-8   文件: HelloServer.java
public static void main(String[] args) {
    int retryCount = 0;
    while (retryCount < MAX_RETRY) {
        try {
            //HelloServer.set("SETTING TEST ITL");
            // Step 1: Instantiate the Hello servant
            HelloImpl helloRef = new HelloImpl();

            // Step 2: Publish the reference in the Naming Service
            // using JNDI API
            Context initialNamingContext = new InitialContext();
            initialNamingContext.rebind("HelloService", helloRef);

            System.out.println("Hello Server: Ready...");
            break;
        } catch (Exception e) {
            System.out.println("Server initialization problem: " + e);
            e.printStackTrace();
            retryCount++;
            try {
                Thread.sleep(ONE_SECOND);
            } catch (InterruptedException e1) {
                e1.printStackTrace();
            }
        }
    }
}
 
源代码9 项目: openjdk-jdk8u   文件: HelloServer.java
public static void main(String[] args) {
    int retryCount = 0;
    while (retryCount < MAX_RETRY) {
        try {
            //HelloServer.set("SETTING TEST ITL");
            // Step 1: Instantiate the Hello servant
            HelloImpl helloRef = new HelloImpl();

            // Step 2: Publish the reference in the Naming Service
            // using JNDI API
            Context initialNamingContext = new InitialContext();
            initialNamingContext.rebind("HelloService", helloRef);

            System.out.println("Hello Server: Ready...");
            break;
        } catch (Exception e) {
            System.out.println("Server initialization problem: " + e);
            e.printStackTrace();
            retryCount++;
            try {
                Thread.sleep(ONE_SECOND);
            } catch (InterruptedException e1) {
                e1.printStackTrace();
            }
        }
    }
}
 
源代码10 项目: openjdk-jdk8u-backup   文件: HelloServer.java
public static void main(String[] args) {
    int retryCount = 0;
    while (retryCount < MAX_RETRY) {
        try {
            //HelloServer.set("SETTING TEST ITL");
            // Step 1: Instantiate the Hello servant
            HelloImpl helloRef = new HelloImpl();

            // Step 2: Publish the reference in the Naming Service
            // using JNDI API
            Context initialNamingContext = new InitialContext();
            initialNamingContext.rebind("HelloService", helloRef);

            System.out.println("Hello Server: Ready...");
            break;
        } catch (Exception e) {
            System.out.println("Server initialization problem: " + e);
            e.printStackTrace();
            retryCount++;
            try {
                Thread.sleep(ONE_SECOND);
            } catch (InterruptedException e1) {
                e1.printStackTrace();
            }
        }
    }
}
 
源代码11 项目: openjdk-jdk8u-backup   文件: HelloServer.java
public static void main(String[] args) {
    int retryCount = 0;
    while (retryCount < MAX_RETRY) {
        try {
            //HelloServer.set("SETTING TEST ITL");
            // Step 1: Instantiate the Hello servant
            HelloImpl helloRef = new HelloImpl();

            // Step 2: Publish the reference in the Naming Service
            // using JNDI API
            Context initialNamingContext = new InitialContext();
            initialNamingContext.rebind("HelloService", helloRef);

            System.out.println("Hello Server: Ready...");
            break;
        } catch (Exception e) {
            System.out.println("Server initialization problem: " + e);
            e.printStackTrace();
            retryCount++;
            try {
                Thread.sleep(ONE_SECOND);
            } catch (InterruptedException e1) {
                e1.printStackTrace();
            }
        }
    }
}
 
源代码12 项目: openjdk-jdk9   文件: HelloServer.java
public static void main(String[] args) {
    int retryCount = 0;
    while (retryCount < MAX_RETRY) {
        try {
            //HelloServer.set("SETTING TEST ITL");
            // Step 1: Instantiate the Hello servant
            HelloImpl helloRef = new HelloImpl();

            // Step 2: Publish the reference in the Naming Service
            // using JNDI API
            Context initialNamingContext = new InitialContext();
            initialNamingContext.rebind("HelloService", helloRef);

            System.out.println("Hello Server: Ready...");
            break;
        } catch (Exception e) {
            System.out.println("Server initialization problem: " + e);
            e.printStackTrace();
            retryCount++;
            try {
                Thread.sleep(ONE_SECOND);
            } catch (InterruptedException e1) {
                e1.printStackTrace();
            }
        }
    }
}
 
源代码13 项目: hibersap   文件: JndiUtil.java
public static void rebindSessionManager(final SessionManager sessionManager, final String jndiName) {
    LOG.info("Binding Hibersap SessionManager '" + sessionManager.getConfig().getName()
            + "' to JNDI name '" + jndiName + "'");

    try {
        Context ctx = new InitialContext();
        ctx.rebind(jndiName, sessionManager);
    } catch (NamingException e) {
        throw new HibersapException("Failed binding Hibersap SessionManager to JNDI name [" + jndiName + "]", e);
    }
}
 
源代码14 项目: jdk8u-jdk   文件: HelloServer.java
public static void main(String[] args) {
    int retryCount = 0;
    while (retryCount < MAX_RETRY) {
        try {
            //HelloServer.set("SETTING TEST ITL");
            // Step 1: Instantiate the Hello servant
            HelloImpl helloRef = new HelloImpl();

            // Step 2: Publish the reference in the Naming Service
            // using JNDI API
            Context initialNamingContext = new InitialContext();
            initialNamingContext.rebind("HelloService", helloRef);

            System.out.println("Hello Server: Ready...");
            break;
        } catch (Exception e) {
            System.out.println("Server initialization problem: " + e);
            e.printStackTrace();
            retryCount++;
            try {
                Thread.sleep(ONE_SECOND);
            } catch (InterruptedException e1) {
                e1.printStackTrace();
            }
        }
    }
}
 
源代码15 项目: hottub   文件: HelloServer.java
public static void main(String[] args) {
    int retryCount = 0;
    while (retryCount < MAX_RETRY) {
        try {
            //HelloServer.set("SETTING TEST ITL");
            // Step 1: Instantiate the Hello servant
            HelloImpl helloRef = new HelloImpl();

            // Step 2: Publish the reference in the Naming Service
            // using JNDI API
            Context initialNamingContext = new InitialContext();
            initialNamingContext.rebind("HelloService", helloRef);

            System.out.println("Hello Server: Ready...");
            break;
        } catch (Exception e) {
            System.out.println("Server initialization problem: " + e);
            e.printStackTrace();
            retryCount++;
            try {
                Thread.sleep(ONE_SECOND);
            } catch (InterruptedException e1) {
                e1.printStackTrace();
            }
        }
    }
}
 
源代码16 项目: jdk8u_jdk   文件: HelloServer.java
public static void main(String[] args) {
    int retryCount = 0;
    while (retryCount < MAX_RETRY) {
        try {
            //HelloServer.set("SETTING TEST ITL");
            // Step 1: Instantiate the Hello servant
            HelloImpl helloRef = new HelloImpl();

            // Step 2: Publish the reference in the Naming Service
            // using JNDI API
            Context initialNamingContext = new InitialContext();
            initialNamingContext.rebind("HelloService", helloRef);

            System.out.println("Hello Server: Ready...");
            break;
        } catch (Exception e) {
            System.out.println("Server initialization problem: " + e);
            e.printStackTrace();
            retryCount++;
            try {
                Thread.sleep(ONE_SECOND);
            } catch (InterruptedException e1) {
                e1.printStackTrace();
            }
        }
    }
}
 
源代码17 项目: jdk8u_jdk   文件: HelloServer.java
public static void main(String[] args) {
    int retryCount = 0;
    while (retryCount < MAX_RETRY) {
        try {
            //HelloServer.set("SETTING TEST ITL");
            // Step 1: Instantiate the Hello servant
            HelloImpl helloRef = new HelloImpl();

            // Step 2: Publish the reference in the Naming Service
            // using JNDI API
            Context initialNamingContext = new InitialContext();
            initialNamingContext.rebind("HelloService", helloRef);

            System.out.println("Hello Server: Ready...");
            break;
        } catch (Exception e) {
            System.out.println("Server initialization problem: " + e);
            e.printStackTrace();
            retryCount++;
            try {
                Thread.sleep(ONE_SECOND);
            } catch (InterruptedException e1) {
                e1.printStackTrace();
            }
        }
    }
}
 
源代码18 项目: cacheonix-core   文件: HelloImpl.java
public void start() throws Exception
{
   if (!m_isRunning)
   {
      // export the remote object
      PortableRemoteObject.exportObject(this);
      // set up the initialContext
      Context ctx = new InitialContext();
      ctx.rebind(IIOP_JNDI_NAME, this);
      System.out.println("My Service servant started successfully");
      m_isRunning = true;
   }
}
 
源代码19 项目: oodt   文件: AvroExecServer.java
public void run() {
    while (shouldKeepBinding()) try {
        Context objectContext = configuration.getObjectContext();
        objectContext.rebind(name, server.getServant());
        objectContext.close();
    } catch (Throwable ex) {
        System.err.println("Exception binding at " + new Date() + "; will keep trying...");
        ex.printStackTrace();
    } finally {
        try {
            Thread.sleep(REBIND_PERIOD);
        } catch (InterruptedException ignore) {}
    }
}
 
源代码20 项目: wildfly-camel   文件: AzureIntegrationTest.java
private CamelContext createCamelContext(StorageCredentials creds) throws Exception {
    WildFlyCamelContext camelctx = new WildFlyCamelContext();
    Context jndictx = camelctx.getNamingContext();
    jndictx.rebind("creds", creds);
    return camelctx;
}