cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl DefaultAspectDataHandler.java AspectUtil.java
Date Thu, 11 Dec 2003 09:56:58 GMT
cziegeler    2003/12/11 01:56:58

  Modified:    src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl
                        DefaultAspectDataHandler.java AspectUtil.java
  Log:
  Auto-conversion of aspect datas
  
  Revision  Changes    Path
  1.4       +2 -2      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl/DefaultAspectDataHandler.java
  
  Index: DefaultAspectDataHandler.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl/DefaultAspectDataHandler.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultAspectDataHandler.java	20 Oct 2003 13:36:41 -0000	1.3
  +++ DefaultAspectDataHandler.java	11 Dec 2003 09:56:58 -0000	1.4
  @@ -181,7 +181,7 @@
           AspectDataStore store = null;
           try {
               store = (AspectDataStore)this.storeSelector.select(aspectDesc.getStoreName());
  -            store.setAspectData(owner, aspectName, data);
  +            store.setAspectData(owner, aspectName, AspectUtil.convert(aspectDesc, data));
           } catch (ServiceException ce) {
               throw new CascadingRuntimeException("Unable to lookup aspect data store " +
aspectDesc.getStoreName(), ce);
           } finally {
  
  
  
  1.4       +23 -1     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl/AspectUtil.java
  
  Index: AspectUtil.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl/AspectUtil.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AspectUtil.java	17 Jun 2003 19:59:32 -0000	1.3
  +++ AspectUtil.java	11 Dec 2003 09:56:58 -0000	1.4
  @@ -88,4 +88,26 @@
           }
       }
       
  +    public static Object convert(AspectDescription desc, Object value) {
  +        try {
  +            Class clazz = ClassUtils.loadClass(desc.getClassName());
  +            if ( clazz.getName().startsWith("java.lang.")) {
  +                if ( !clazz.equals(value.getClass())) {
  +                    Constructor constructor = clazz.getConstructor(new Class[] {String.class});
  +                    return constructor.newInstance(new String[] {value.toString()});
  +                } else {
  +                    return value;
  +                }
  +            } else {
  +                if ( !value.getClass().equals(clazz) ) {
  +                    // FIXME - this is catch by "ignore"
  +                    throw new RuntimeException("Class of aspect doesn't match description.");
  +                }
  +                return value;
  +            }
  +        } catch (Exception ignore) {
  +            // if we can't convert, well we don't do it :)
  +            return value;
  +        }        
  +    }
   }
  
  
  

Mime
View raw message