[Design of POJO Server] - Re: VFS Permissions - JBMICROCONT-149
by david.lloyd@jboss.com
No, I disagree entirely. Actually it's fine if it's a VFS URL. We've already gotten past that problem - we can specify VFS URLs in the security policy file now without any problems.
The problem now is that vfsmemory URLs are not predictable. And in fact -any- VFS URL type might not have a corresponding "real" URL; I don't think this is a reliable solution.
I think the best solution is to have predictable/repeatable names for VFS URLs. I don't think using a UUID is really useful in practice anyway. Why not allow a name to be assigned to vfsmemory URLs? Then one could simply put the appropriate vfsmemory URL in the security policy file. If security is a concern, one could simply introduce a permission that is necessary in order to create a vfsmemory URL with a given name.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4190941#4190941
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4190941
17 years, 4 months
[Design the new POJO MicroContainer] - Re: UnwrapValueUnitTestCase.testCollectionUnwrap failure on
by adrian@jboss.org
"alesj" wrote : "alesj" wrote :
| | What about if I just change that the key is ClassInfo instead of String?
| | (I've done that locally and all the tests pass)
| Actually I think I can drop the whole ClassLoader as key,
| since ClassInfo is per ClassLoader if I'm not mistaken.
|
But you still have the problem that ClassInfos can be transient.
Let's go with that, but we need to do so extra work to see whether all this
caching is (still) effective.
I think in practice it will work for most of the ClassInfos we use to create beans
since the WeakTypeCache will hold a reference to the TypeInfo until the bean's class
is GCed.
But for more transient bean classes, e.g. those used only in the managed object layer
it might not be as good?
If only there was a combination Weak/SoftReference mechanism
which let you do SoftReference behaviour until the classloader gets GCed
then it turns into WeakReference behaviour. ;-)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4190936#4190936
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4190936
17 years, 4 months
[Design the new POJO MicroContainer] - Re: UnwrapValueUnitTestCase.testCollectionUnwrap failure on
by adrian@jboss.org
I don't know how to make the test fail, but the following
change to the test shows the problem happening.
| Index: src/test/java/org/jboss/test/metatype/values/factory/test/UnwrapValueUnitTestCase.java
| ===================================================================
| --- src/test/java/org/jboss/test/metatype/values/factory/test/UnwrapValueUnitTestCase.java (revision 81358)
| +++ src/test/java/org/jboss/test/metatype/values/factory/test/UnwrapValueUnitTestCase.java (working copy)
| @@ -35,7 +35,10 @@
|
| import junit.framework.Test;
|
| +import org.jboss.beans.info.spi.BeanInfo;
| +import org.jboss.config.plugins.property.PropertyConfiguration;
| import org.jboss.metatype.api.values.MetaValue;
| +import org.jboss.reflect.spi.ClassInfo;
| import org.jboss.test.metatype.values.factory.support.SimpleCompositeInterface;
| import org.jboss.test.metatype.values.factory.support.TestEnum;
| import org.jboss.test.metatype.values.factory.support.TestGeneric;
| @@ -103,9 +106,21 @@
|
| checkSingle(new TestSimpleCompositeInterface("something"), SimpleCompositeInterface.class);
| }
| + PropertyConfiguration config = new PropertyConfiguration();
|
| + private void printCollection(Type type)
| + {
| + ClassInfo typeInfo = (ClassInfo) config.getTypeInfo(type);
| + System.out.println(typeInfo.getName() + " " + typeInfo.getComponentType());
| + BeanInfo beanInfo = config.getBeanInfo(typeInfo);
| + typeInfo = beanInfo.getClassInfo();
| + System.out.println(typeInfo.getName() + " " + typeInfo.getComponentType());
| + }
| +
| public void testCollectionUnwrap() throws Exception
| {
| + printCollection(getType("Integer", Set.class));
| + printCollection(getType("Enum", Set.class));
| Integer i1 = 123;
| Integer i2 = 123;
| checkCollection(new ArrayList<Integer>(), i1, i2);
|
which produces output (the last line is wrong)
| java.util.Set java.lang.Integer
| java.util.Set java.lang.Integer
| java.util.Set EnumInfoImpl(a)1df280b{name=org.jboss.test.metatype.values.factory.support.TestEnum}
| java.util.Set java.lang.Integer
|
So it looks like the BeanInfo caching is the problem.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4190928#4190928
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4190928
17 years, 4 months
[Design the new POJO MicroContainer] - Re: UnwrapValueUnitTestCase.testCollectionUnwrap failure on
by alesj
"alesj" wrote :
| What about if I just change that the key is ClassInfo instead of String?
| (I've done that locally and all the tests pass)
Actually I think I can drop the whole ClassLoader as key,
since ClassInfo is per ClassLoader if I'm not mistaken.
| Index: src/main/java/org/jboss/beans/info/plugins/AbstractBeanInfoFactory.java
| ===================================================================
| --- src/main/java/org/jboss/beans/info/plugins/AbstractBeanInfoFactory.java (revision 79796)
| +++ src/main/java/org/jboss/beans/info/plugins/AbstractBeanInfoFactory.java (working copy)
| @@ -55,7 +55,7 @@
| public class AbstractBeanInfoFactory implements BeanInfoFactory
| {
| /** The cache */
| - protected Map<ClassLoader, Map<String, Map<BeanAccessMode, BeanInfo>>> cache = new WeakHashMap<ClassLoader, Map<String, Map<BeanAccessMode, BeanInfo>>>();
| + protected Map<ClassInfo, Map<BeanAccessMode, BeanInfo>> cache = new WeakHashMap<ClassInfo, Map<BeanAccessMode, BeanInfo>>();
|
| protected static boolean isGetter(MethodInfo minfo)
| {
| @@ -133,20 +133,14 @@
|
| synchronized (cache)
| {
| - ClassLoader cl = classAdapter.getClassLoader();
| ClassInfo classInfo = classAdapter.getClassInfo();
| - String className = classInfo.getName();
| - Map<String, Map<BeanAccessMode, BeanInfo>> map = cache.get(cl);
| - Map<BeanAccessMode, BeanInfo> modeMap = null;
| - if (map != null)
| + //String className = classInfo.getName();
| + Map<BeanAccessMode, BeanInfo> modeMap = cache.get(classInfo);
| + if (modeMap != null)
| {
| - modeMap = map.get(className);
| - if (modeMap != null)
| - {
| - BeanInfo info = modeMap.get(accessMode);
| - if (info != null)
| - return info;
| - }
| + BeanInfo info = modeMap.get(accessMode);
| + if (info != null)
| + return info;
| }
|
| Set<ConstructorInfo> constructors = getConstructors(classInfo);
| @@ -159,16 +153,9 @@
| Set<EventInfo> events = getEvents(classInfo);
|
| BeanInfo result = createBeanInfo(classAdapter, accessMode, properties, constructors, methods, events);
| - if (map == null)
| - {
| - map = new WeakValueHashMap<String, Map<BeanAccessMode, BeanInfo>>();
| - cache.put(cl, map);
| - }
| if (modeMap == null)
| - {
| modeMap = new WeakValueHashMap<BeanAccessMode, BeanInfo>();
| - map.put(className, modeMap);
| - }
| +
| modeMap.put(accessMode, result);
| return result;
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4190911#4190911
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4190911
17 years, 4 months