List of usage examples for javax.naming Reference getClassName
public String getClassName()
From source file:org.nuxeo.runtime.jtajca.NuxeoTransactionManagerFactory.java
@Override public Object getObjectInstance(Object obj, Name objName, Context nameCtx, Hashtable<?, ?> env) { Reference ref = (Reference) obj; if (!TransactionManager.class.getName().equals(ref.getClassName())) { return null; }/*from w ww . j av a 2 s. c o m*/ if (NuxeoContainer.tm != null) { return NuxeoContainer.tm; } // initialize TransactionManagerConfiguration config = new TransactionManagerConfiguration(); for (RefAddr addr : Collections.list(ref.getAll())) { String name = addr.getType(); String value = (String) addr.getContent(); try { BeanUtils.setProperty(config, name, value); } catch (ReflectiveOperationException e) { log.error(String.format("NuxeoTransactionManagerFactory cannot set %s = %s", name, value)); } } return NuxeoContainer.initTransactionManager(config); }
From source file:org.soulwing.cas.client.ProtocolConfigurationFactory.java
public Object getObjectInstance(Object o, Name name, Context ctx, Hashtable env) throws Exception { if (o == null || !(o instanceof Reference)) { log.error("expected a Reference object"); return null; }//from w ww . ja v a 2 s . com Reference ref = (Reference) o; if (!ProtocolConfiguration.class.isAssignableFrom(Class.forName(ref.getClassName()))) { log.error("expected a reference type of " + ProtocolConfiguration.class.getCanonicalName()); return null; } RefAddr ra = null; ProtocolConfigurationImpl config = new ProtocolConfigurationImpl(); ra = ref.get("serverUrl"); if (ra != null) { config.setServerUrl(ra.getContent().toString()); } else { log.error("serverUrl property is required"); return null; } ra = ref.get("serviceUrl"); if (ra != null) { config.setServiceUrl(ra.getContent().toString()); } ra = ref.get("proxyCallbackUrl"); if (ra != null) { config.setProxyCallbackUrl(ra.getContent().toString()); } ra = ref.get("renew"); if (ra != null) { config.setRenewFlag(Boolean.parseBoolean(ra.getContent().toString().toLowerCase())); } ra = ref.get("gateway"); if (ra != null) { config.setGatewayFlag(Boolean.parseBoolean(ra.getContent().toString().toLowerCase())); } return config; }
From source file:ru.zinin.redis.factory.JedisPoolFactory.java
/** {@inheritDoc} */ @Override/*from w w w. j a v a2s. co m*/ public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception { if ((obj == null) || !(obj instanceof Reference)) { return (null); } Reference ref = (Reference) obj; if (!"redis.clients.jedis.JedisPool".equals(ref.getClassName())) { return (null); } String host = "localhost"; int port = Protocol.DEFAULT_PORT; int timeout = Protocol.DEFAULT_TIMEOUT; String password = null; RefAddr hostRefAddr = ref.get("host"); if (hostRefAddr != null) { host = hostRefAddr.getContent().toString(); } RefAddr portRefAddr = ref.get("port"); if (portRefAddr != null) { port = Integer.parseInt(portRefAddr.getContent().toString()); } RefAddr timeoutRefAddr = ref.get("timeout"); if (timeoutRefAddr != null) { timeout = Integer.parseInt(timeoutRefAddr.getContent().toString()); } RefAddr passwordRefAddr = ref.get("password"); if (passwordRefAddr != null) { password = passwordRefAddr.getContent().toString(); } log.debug("Creating pool..."); log.debug("Host: " + host); log.debug("Port: " + port); log.debug("Timeout: " + timeout); log.trace("Password: " + password); JedisPoolConfig config = new JedisPoolConfig(); RefAddr maxActiveRefAddr = ref.get("max-active"); if (maxActiveRefAddr != null) { int maxActive = Integer.parseInt(maxActiveRefAddr.getContent().toString()); log.debug("Setting maxActive to " + maxActive); config.maxActive = maxActive; } return new JedisPool(config, host, port, timeout, password); }