Java 8 Reference - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Reference class.

This code example shows how to use the following methods:get, getClassName
        if (trace.isDebugEnabled()) {
            trace.debug("getObjectInstance obj={0} name={1} nameCtx={2} environment={3}", obj, name, nameCtx, environment);
        } 
        if (obj instanceof Reference) {
            Reference ref = (Reference) obj;
            if (ref.getClassName().equals(JdbcDataSource.class.getName())) {
                JdbcDataSource dataSource = new JdbcDataSource();
                dataSource.setURL((String) ref.get("url").getContent());
                dataSource.setUser((String) ref.get("user").getContent());
                dataSource.setPassword((String) ref.get("password").getContent());
                dataSource.setDescription((String) ref.get("description").getContent());
                String s = (String) ref.get("loginTimeout").getContent();
                dataSource.setLoginTimeout(Integer.parseInt(s));
                return dataSource;
            } 
        } 
        return null; 
    } 
 
    /** 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:get
    return keyspace;
  } 
   
  private void configure(Reference resourceRef) throws Exception {
 // required 
    RefAddr hostsRefAddr = resourceRef.get("hosts");
    RefAddr clusterNameRef = resourceRef.get("clusterName");
    RefAddr keyspaceNameRef = resourceRef.get("keyspace");
    // optional 
    RefAddr maxActiveRefAddr = resourceRef.get("maxActive");
    RefAddr maxWaitTimeWhenExhausted = resourceRef.get("maxWaitTimeWhenExhausted");
    RefAddr maxExhaustedTimeBeforeMarkingAsDown = resourceRef.get("maxExhaustedTimeBeforeMarkingAsDown");
    RefAddr autoDiscoverHosts = resourceRef.get("autoDiscoverHosts");
    RefAddr runAutoDiscoverAtStartup = resourceRef.get("runAutoDiscoveryAtStartup");
    RefAddr retryDownedHostDelayInSeconds = resourceRef.get("retryDownedHostDelayInSeconds");
     
    if ( hostsRefAddr == null || hostsRefAddr.getContent() == null) {
      throw new Exception("A url and port on which Cassandra is installed and listening " + 
      "on must be provided as a ResourceParams in the context.xml"); 
    }         
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:get, getClassName
   */ 
  public synchronized Object getObjectInstance(Object obj, Name name,
      Context nameCtx, Hashtable<?, ?> environment) {
    if (obj instanceof Reference) {
      Reference ref = (Reference) obj;
      if (ref.getClassName().equals(JdbcDataSource.class.getName())) {
        JdbcDataSource dataSource = new JdbcDataSource(conf);
        dataSource.setURL((String) ref.get("url").getContent());
        dataSource.setUser((String) ref.get("user").getContent());
        dataSource.setPassword((String) ref.get("password").getContent());
        dataSource.setDescription((String) ref.get("description").getContent());
        String s = (String) ref.get("loginTimeout").getContent();
        dataSource.setLoginTimeout(Integer.parseInt(s));
        return dataSource;
      } 
    } 
    return null; 
  } 
 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:get, getClassName
                                    Hashtable environment) throws Exception {
 
        String    dsClass = "org.hsqldb_voltpatches.jdbc.JDBCDataSource";
        Reference ref     = (Reference) obj;
 
        if (ref.getClassName().equals(dsClass)) {
            JDBCDataSource ds = new JDBCDataSource();
 
            ds.setDatabase((String) ref.get("database").getContent());
            ds.setUser((String) ref.get("user").getContent());
            ds.setPassword((String) ref.get("password").getContent());
 
            return ds;
        } else { 
            return null; 
        } 
    } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:get, getClassName
            trace.debug("getObjectInstance obj={0} name={1} " +
                    "nameCtx={2} environment={3}", obj, name, nameCtx, environment);
        } 
        if (obj instanceof Reference) {
            Reference ref = (Reference) obj;
            if (ref.getClassName().equals(JdbcDataSource.class.getName())) {
                JdbcDataSource dataSource = new JdbcDataSource();
                dataSource.setURL((String) ref.get("url").getContent());
                dataSource.setUser((String) ref.get("user").getContent());
                dataSource.setPassword((String) ref.get("password").getContent());
                dataSource.setDescription((String) ref.get("description").getContent());
                String s = (String) ref.get("loginTimeout").getContent();
                dataSource.setLoginTimeout(Integer.parseInt(s));
                return dataSource;
            } 
        } 
        return null; 
    } 
 
    /** 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:get, getClassName
        // that specify a class name of "org.apache.catalina.UserDatabase" 
        if ((obj == null) || !(obj instanceof Reference)) {
            return (null); 
        } 
        Reference ref = (Reference) obj;
        if (!"org.apache.catalina.UserDatabase".equals(ref.getClassName())) {
            return (null); 
        } 
 
        // Create and configure a MemoryUserDatabase instance based on the 
        // RefAddr values associated with this Reference 
        MemoryUserDatabase database = new MemoryUserDatabase(name.toString());
        RefAddr ra = null;
 
        ra = ref.get("pathname");
        if (ra != null) {
            database.setPathname(ra.getContent().toString());
        } 
 
        ra = ref.get("readonly");

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:get
    @SuppressWarnings("unchecked") // Avoid warnings on deserialization 
    @Override 
    protected InstanceKeyDataSource getNewInstance(Reference ref)
        throws IOException, ClassNotFoundException {
        PerUserPoolDataSource pupds =  new PerUserPoolDataSource();
        RefAddr ra = ref.get("defaultMaxTotal");
        if (ra != null && ra.getContent() != null) {
            pupds.setDefaultMaxTotal(
                Integer.parseInt(ra.getContent().toString()));
        } 
 
        ra = ref.get("defaultMaxIdle");
        if (ra != null && ra.getContent() != null) {
            pupds.setDefaultMaxIdle(
                Integer.parseInt(ra.getContent().toString()));
        } 
 
        ra = ref.get("defaultMaxWaitMillis");
        if (ra != null && ra.getContent() != null) {
            pupds.setDefaultMaxWaitMillis(

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:add
    /** 
     * @param on ObjectName instance to work with. 
     * @return A simple reference based on passed <code>on</code> 
     */ 
    public static Reference getReference(final ObjectName on) {
       Reference r = new Reference(String.class.getName());
       Hashtable<String,String> ht = on.getKeyPropertyList();
       r.add(new StringRefAddr("host", (String)ht.get("host")));
       r.add(new StringRefAddr("name", (String)ht.get("name")));
       // Put in a value to serve as a unique 'key'. 
       r.add(new StringRefAddr("key",
               on.getCanonicalKeyPropertyListString()));
       return r;
    } 
     
    /** 
     * Get subcontext.  Only looks down one level. 
     * @param subContext Name of subcontext to return. 
     * @return Sub context. 
     * @throws NamingException  

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:add
    } 
 
    @Test
    public void shouldReturnSameRepository() throws Exception {
        configFile = new StringRefAddr("configFile", "tck/default/repo-config.json");
        reference.add(configFile);
        reference.add(repositoryName);
 
        JcrRepository repo1 = null;
        JcrRepository repo2 = null;
        try { 
            repo1 = (JcrRepository)factory.getObjectInstance(reference, null, null, null);
            repo2 = (JcrRepository)factory.getObjectInstance(reference, null, null, null);
            assertThat(repo1 == repo2, is(true));
        } finally { 
            try { 
                if (repo1 != null) repo1.shutdown();
            } finally { 
                if (repo2 != null) repo2.shutdown();
            } 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:get, getClassName
        if (trace.isDebugEnabled()) {
            trace.debug("getObjectInstance obj={0} name={1} nameCtx={2} environment={3}", obj, name, nameCtx, environment);
        } 
        if (obj instanceof Reference) {
            Reference ref = (Reference) obj;
            if (ref.getClassName().equals(JdbcDataSource.class.getName())) {
                JdbcDataSource dataSource = new JdbcDataSource();
                dataSource.setURL((String) ref.get("url").getContent());
                dataSource.setUser((String) ref.get("user").getContent());
                dataSource.setPassword((String) ref.get("password").getContent());
                dataSource.setDescription((String) ref.get("description").getContent());
                String s = (String) ref.get("loginTimeout").getContent();
                dataSource.setLoginTimeout(Integer.parseInt(s));
                return dataSource;
            } 
        } 
        return null; 
    } 
 
    /** 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 Reference Methods: