List of usage examples for org.springframework.beans.factory.config PropertyPathFactoryBean PropertyPathFactoryBean
PropertyPathFactoryBean
From source file:marshalsec.gadgets.SpringPropertyPathFactory.java
@Primary @Args(minArgs = 1, args = { "jndiUrl" }, defaultArgs = { MarshallerBase.defaultJNDIUrl }) default Object makePropertyPathFactory(UtilFactory uf, String[] args) throws Exception { String jndiUrl = args[0];//from ww w. j a v a2 s. c o m BeanFactory bf = SpringUtil.makeJNDITrigger(jndiUrl); PropertyPathFactoryBean ppf = new PropertyPathFactoryBean(); ppf.setTargetBeanName(jndiUrl); ppf.setPropertyPath("foo"); Reflections.setFieldValue(ppf, "beanFactory", bf); return ppf; }
From source file:marshalsec.Red5AMFBase.java
@Override @Args(minArgs = 1, args = { "jndiUrl" }, defaultArgs = { MarshallerBase.defaultJNDIUrl }) public Object makePropertyPathFactory(UtilFactory uf, String[] args) throws Exception { String jndiUrl = args[0];//from w w w . j av a 2 s .c o m PropertyInjectingProxy bfproxy = new PropertyInjectingProxy(new SimpleJndiBeanFactory(), Collections.singletonMap("shareableResources", new String[] { jndiUrl })); // RED5 uses a regular HashMap to temporarily store the property values // // To make sure the property setters are called in the right order we // have to make sure that they end up in bins matching that order Map<String, Object> values = new LinkedHashMap<>(); int size = 16; for (; size < Short.MAX_VALUE; size = size << 1) { long p = mapHash("propertyPath".hashCode() & 0xFFFFFFFFL) % size; long t = mapHash("targetBeanName".hashCode() & 0xFFFFFFFFL) % size; long b = mapHash("beanFactory".hashCode() & 0xFFFFFFFFL) % size; if (p <= b && t <= b) { System.err.println( String.format("propertyPath @ %d targetBeanName @ %d beanFactory @ %d with table size %d", p, t, b, size)); break; } } values.put("propertyPath", "a"); values.put("targetBeanName", jndiUrl); values.put("beanFactory", bfproxy); // this blows up the table to the desired size // keys must be distributed more or less evenly or the hash table won't expand to the desired size for (int j = 0; j < size / 2; j++) { values.put("" + j, ""); } return new PropertyInjectingProxy(new PropertyPathFactoryBean(), values); }
From source file:marshalsec.BlazeDSBase.java
@Override @Args(minArgs = 1, args = { "jndiUrl" }, defaultArgs = { MarshallerBase.defaultJNDIUrl }) public Object makePropertyPathFactory(UtilFactory uf, String[] args) throws Exception { String jndiUrl = args[0];//from ww w .j a v a 2 s . c o m PropertyInjectingProxy bfproxy = new PropertyInjectingProxy(new SimpleJndiBeanFactory(), Collections.singletonMap("shareableResources", Arrays.asList(jndiUrl) // this would actually be an array, // but AMFX has some trouble with // non-readable array properties )); Map<String, Object> values = new LinkedHashMap<>(); values.put("targetBeanName", jndiUrl); values.put("propertyPath", "foo"); values.put("beanFactory", bfproxy); return new PropertyInjectingProxy(new PropertyPathFactoryBean(), values); }