cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexey Katorgin <progmons...@gmail.com>
Subject Re: No way to remove Context user property
Date Fri, 09 Nov 2012 04:29:16 GMT
Very strange what my question still has no answers. I'll try to be more clear:

        ServerRuntime runtime = ...;

        ObjectContext ctx = runtime.getContext();
        
        ctx.setUserProperty("my-property", "value");
        
        ctx.setUserProperty("my-property", null); // throws NPE and no another 
way to delete property.

        /// Workaround:
        // Define global constant: public static final Object EMPTY_VALUE = new 
Object();

        // Clear property:
        ctx.setUserProperty("my-property", EMPTY_VALUE);
        
        // Check if empty:        
        if (EMPTY_VALUE.equals(ctx.getUserProperty("my-property"))) {
            // ...
        }
        
        // Should have in API anything like:
        ctx.removeUserProperty("my-property");


May be should I ask this question to devel group?


Thanks,
Alexey Katorgin.



Mime
View raw message