congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
Reference
Code IndexAdd Tabnine to your IDE (free)

How to use
Reference
in
javax.naming

Best Java code snippets using javax.naming.Reference (Showing top 20 results out of 2,403)

Refine searchRefine arrow

  • RefAddr
  • StringRefAddr
  • InitialContext
  • Enumeration
  • NamingException
  • Context
  • Properties
origin: wildfly/wildfly

/**
* Create a Reference instance from a JNDIStorable object
*
* @param instanceClassName
*     The name of the class that is being created.
* @param po
*     The properties object to use when configuring the new instance.
*
* @return Reference
*
* @throws NamingException if an error occurs while creating the new instance.
*/
public static Reference createReference(String instanceClassName, JNDIStorable po) throws NamingException {
 Reference result = new Reference(instanceClassName, JNDIReferenceFactory.class.getName(), null);
 try {
   Properties props = po.getProperties();
   for (Enumeration iter = props.propertyNames(); iter.hasMoreElements();) {
    String key = (String)iter.nextElement();
    result.add(new StringRefAddr(key, props.getProperty(key)));
   }
 } catch (Exception e) {
   throw new NamingException(e.getMessage());
 }
 return result;
}
origin: alibaba/druid

@Override
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment)
    throws Exception {
  // We only know how to deal with <code>javax.naming.Reference</code>s
  // that specify a class name of "javax.sql.DataSource"
  if ((obj == null) || !(obj instanceof Reference)) {
    return null;
  }
  Reference ref = (Reference) obj;
  if ((!"javax.sql.DataSource".equals(ref.getClassName())) //
      && (!"com.alibaba.druid.pool.DruidDataSource".equals(ref.getClassName())) //
  ) {
    return null;
  }
  Properties properties = new Properties();
  for (int i = 0; i < ALL_PROPERTIES.length; i++) {
    String propertyName = ALL_PROPERTIES[i];
    RefAddr ra = ref.get(propertyName);
    if (ra != null) {
      String propertyValue = ra.getContent().toString();
      properties.setProperty(propertyName, propertyValue);
    }
  }
  return createDataSourceInternal(properties);
}
origin: wildfly/wildfly

public static Properties getProperties(Reference reference) {
 Properties properties = new Properties();
 for (Enumeration iter = reference.getAll(); iter.hasMoreElements();) {
   StringRefAddr addr = (StringRefAddr)iter.nextElement();
   properties.put(addr.getType(), (addr.getContent() == null) ? "" : addr.getContent());
 }
 return properties;
}
origin: alibaba/druid

public Reference getReference() throws NamingException {
  final String className = getClass().getName();
  final String factoryName = className + "Factory"; // XXX: not robust
  Reference ref = new Reference(className, factoryName, null);
  ref.add(new StringRefAddr("instanceKey", instanceKey));
  ref.add(new StringRefAddr("url", this.getUrl()));
  ref.add(new StringRefAddr("username", this.getUsername()));
  ref.add(new StringRefAddr("password", this.getPassword()));
  // TODO ADD OTHER PROPERTIES
  return ref;
}
origin: wildfly/wildfly

static ObjectFactory lookForURLs(Reference ref, Hashtable environment)
    throws NamingException {
  for (int i = 0; i < ref.size(); i++) {
    RefAddr addr = ref.get(i);
    if (addr instanceof StringRefAddr &&
        addr.getType().equalsIgnoreCase("URL")) {
      String url = (String) addr.getContent();
      ObjectFactory answer = processURL(url, environment);
      if (answer != null) {
        return answer;
      }
    }
  }
  return null;
}
origin: com.zaxxer/HikariCP

@Override
synchronized public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception
{
 // We only know how to deal with <code>javax.naming.Reference</code> that specify a class name of "javax.sql.DataSource"
 if (obj instanceof Reference && "javax.sql.DataSource".equals(((Reference) obj).getClassName())) {
   Reference ref = (Reference) obj;
   Set<String> hikariPropSet = PropertyElf.getPropertyNames(HikariConfig.class);
   Properties properties = new Properties();
   Enumeration<RefAddr> enumeration = ref.getAll();
   while (enumeration.hasMoreElements()) {
    RefAddr element = enumeration.nextElement();
    String type = element.getType();
    if (type.startsWith("dataSource.") || hikariPropSet.contains(type)) {
      properties.setProperty(type, element.getContent().toString());
    }
   }
   return createDataSource(properties, nameCtx);
 }
 return null;
}
origin: org.apache.sentry/sentry-shaded-miscellaneous

public Object getObjectInstance(Object object, Name name, Context context, Hashtable<?, ?> table) throws Exception {
  Reference ref = (Reference) object;
  Enumeration<RefAddr> addrs = ref.getAll();
  Properties props = new Properties();
  while (addrs.hasMoreElements()) {
    RefAddr addr = addrs.nextElement();
    if (addr.getType().equals("driverClassName")){
      Class.forName((String) addr.getContent());
    } else {
      props.put(addr.getType(), addr.getContent());
    }
  }        
  BoneCPConfig config = new BoneCPConfig(props);
  return new BoneCPDataSource(config);
}
origin: org.mongodb/mongo-java-driver

Enumeration<RefAddr> props = ((Reference) obj).getAll();
while (props.hasMoreElements()) {
  RefAddr addr = props.nextElement();
  if (addr != null) {
    if (CONNECTION_STRING.equals(addr.getType())) {
      if (addr.getContent() instanceof String) {
        connectionString = (String) addr.getContent();
        break;
origin: io.snappydata/gemfirexd-client

throws SqlException {
  Properties properties = new Properties();
    for (Enumeration e = ref.getAll(); e.hasMoreElements();) {
      RefAddr attribute = (RefAddr) e.nextElement();
      String propertyKey = attribute.getType();
      String value = (String) attribute.getContent();
        properties.setProperty(propertyKey, value);
      e.getClass().getName(), e.getMessage(), e);
origin: apache/activemq-artemis

  public Reference from(Properties properties) {
   String type = (String) properties.remove("type");
   String factory = (String) properties.remove("factory");
   Reference result = new Reference(type, factory, null);
   for (Enumeration iter = properties.propertyNames(); iter.hasMoreElements();) {
     String key = (String)iter.nextElement();
     result.add(new StringRefAddr(key, properties.getProperty(key)));
   }
   return result;
  }
}
origin: org.apache.tomcat/tomcat-catalina

/**
 * Create a new EJB instance using OpenEJB.
 *
 * @param obj The reference object describing the DataSource
 */
@Override
public Object getObjectInstance(Object obj, Name name, Context nameCtx,
                Hashtable<?,?> environment)
  throws Exception {
  Object beanObj = null;
  if (obj instanceof EjbRef) {
    Reference ref = (Reference) obj;
    String factory = DEFAULT_OPENEJB_FACTORY;
    RefAddr factoryRefAddr = ref.get("openejb.factory");
    if (factoryRefAddr != null) {
      // Retrieving the OpenEJB factory
      factory = factoryRefAddr.getContent().toString();
    }
    Properties env = new Properties();
    env.put(Context.INITIAL_CONTEXT_FACTORY, factory);
    RefAddr linkRefAddr = ref.get("openejb.link");
    if (linkRefAddr != null) {
      String ejbLink = linkRefAddr.getContent().toString();
      beanObj = (new InitialContext(env)).lookup(ejbLink);
    }
  }
  return beanObj;
}
origin: internetarchive/heritrix3

  /**
   * Testing code.
   * @param args Command line arguments.
   * @throws NullPointerException 
   * @throws MalformedObjectNameException 
   * @throws NamingException 
   * @throws InvalidNameException 
   */
  public static void main(String[] args)
  throws MalformedObjectNameException, NullPointerException,
  InvalidNameException, NamingException {
    final ObjectName on = new ObjectName("org.archive.crawler:" +
        "type=Service,name=Heritrix00,host=debord.archive.org");
    Context c = getSubContext(getCompoundName(on.getDomain()));
    CompoundName key = bindObjectName(c, on);
    Reference r = (Reference)c.lookup(key);
    for (Enumeration<RefAddr> e = r.getAll(); e.hasMoreElements();) {
      System.out.println(e.nextElement());
    }
    unbindObjectName(c, on);
  }
}
origin: org.apache.jackrabbit/jackrabbit-jcr2spi

/**
 * @see Referenceable#getReference()
 */
public Reference getReference() throws NamingException {
  if (config instanceof Referenceable) {
    Referenceable confref = (Referenceable)config;
    if (reference == null) {
      reference = new Reference(RepositoryImpl.class.getName(), RepositoryImpl.Factory.class.getName(), null);
      // carry over all addresses from referenceable config
      for (Enumeration<RefAddr> en = confref.getReference().getAll(); en.hasMoreElements(); ) {
        reference.add(en.nextElement());
      }
      // also add the information required by factory class
      reference.add(new StringRefAddr(Factory.RCF, confref.getReference().getFactoryClassName()));
      reference.add(new StringRefAddr(Factory.RCC, config.getClass().getName()));
    }
    return reference;
  }
  else {
    throw new javax.naming.OperationNotSupportedException("Contained RepositoryConfig needs to implement javax.naming.Referenceable");
  }
}
origin: org.apache.tomcat/tomcat-catalina

  @Override
  protected Object getLinked(Reference ref) throws NamingException {
    // If ejb-link has been specified, resolving the link using JNDI
    RefAddr linkRefAddr = ref.get(EjbRef.LINK);
    if (linkRefAddr != null) {
      // Retrieving the EJB link
      String ejbLink = linkRefAddr.getContent().toString();
      Object beanObj = (new InitialContext()).lookup(ejbLink);
      return beanObj;
    }
    return null;
  }
}
origin: com.enioka.jqm/jqm-providers

  @Override
  public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception
  {
    Reference resource = (Reference) obj;
    if (resource.get("STRING") != null)
    {
      String res = (String) resource.get("STRING").getContent();
      return res;
    }
    else
    {
      throw new NamingException("Resource does not have a valid STRING parameter");
    }
  }
}
origin: org.jboss.jbossas/jboss-as-server

private void bind() throws NamingException
{
 Context ctx = new InitialContext();
 // Ah ! We aren't serializable, so we use a helper class
 NonSerializableFactory.bind(JNDI_NAME, this);
 
 // The helper class NonSerializableFactory uses address type nns, we go on to
 // use the helper class to bind ourselves in JNDI
 StringRefAddr addr = new StringRefAddr("nns", JNDI_NAME);
 Reference ref = new Reference(EntityLockMonitor.class.getName(), addr, NonSerializableFactory.class.getName(), null);
 ctx.bind(JNDI_NAME, ref);
}
origin: hector-client/hector

 @Test
 public void getObjectInstance() throws Exception {
  Reference resource = new Reference("CassandraClientFactory");

  resource.add(new StringRefAddr("hosts", cassandraUrl));
  resource.add(new StringRefAddr("clusterName", clusterName));
  resource.add(new StringRefAddr("keyspace", "Keyspace1"));
  resource.add(new StringRefAddr("autoDiscoverHosts", "true"));
  

  Name jndiName = mock(Name.class);
  Context context = new InitialContext();
  Hashtable<String, String> environment = new Hashtable<String, String>();

  Keyspace keyspace = (Keyspace) factory.getObjectInstance(resource, jndiName, context, environment);

  assertNotNull(keyspace);
  assertEquals("Keyspace1",keyspace.getKeyspaceName());
 }
}
origin: org.jboss.naming/jnpserver

  public void start() throws Exception
  {
   initialContext();
   ClassLoader topLoader = Thread.currentThread().getContextClassLoader();
   ENCFactory.setTopClassLoader(topLoader);
   RefAddr refAddr = new StringRefAddr("nns", "ENC");
   Reference envRef = new Reference("javax.naming.Context", refAddr, ENCFactory.class.getName(), null);
   Context ctx = (Context)iniCtx.lookup("java:");
   ctx.rebind("comp", envRef);
  }
}
origin: org.postgresql/postgresql

private static String getReferenceProperty(Reference ref, String propertyName) {
 RefAddr addr = ref.get(propertyName);
 if (addr == null) {
  return null;
 }
 return (String) addr.getContent();
}
origin: org.switchyard/switchyard-deploy-jboss-as6

public void visit(DeploymentUnit unit) throws DeploymentException {
  if (unit.isTopLevel()) {
    Context javaComp = getJavaComp(unit);
    try {
      Reference reference = new Reference("javax.enterprise.inject.spi.BeanManager", "org.jboss.weld.integration.deployer.jndi.JBossBeanManagerObjectFactory", null);
      reference.add(new StringRefAddr("id", IdFactory.getIdFromClassLoader(unit.getClassLoader())));
      javaComp.bind("BeanManager", reference);
      _logger.debug("CDI BeanManager successfully bound into JNDI (java:comp) for SwitchYard deployment '" + unit.getName() + "'.");
    } catch (NamingException e) {
      throw new DeploymentException("Error binding BeanManager.", e);
    }
  }
}
  
javax.namingReference

Most used methods

  • <init>
  • get
  • getClassName
  • add
  • getAll
  • getFactoryClassName
  • size
  • getFactoryClassLocation
  • hashCode
  • equals
  • remove
  • remove

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getExternalFilesDir (Context)
  • getApplicationContext (Context)
  • getSharedPreferences (Context)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now