001    package railo.runtime.orm.hibernate.tuplizer.accessors;
002    
003    import java.lang.reflect.Method;
004    
005    import org.hibernate.HibernateException;
006    import org.hibernate.engine.SessionFactoryImplementor;
007    import org.hibernate.property.Setter;
008    
009    import railo.runtime.Component;
010    import railo.runtime.exp.PageException;
011    import railo.runtime.op.Caster;
012    import railo.runtime.orm.hibernate.HibernateRuntimeException;
013    import railo.runtime.type.Collection;
014    import railo.runtime.type.Collection.Key;
015    import railo.runtime.type.KeyImpl;
016    
017    public final class CFCSetter implements Setter {
018            
019            private Key key;
020    
021            /**
022             * Constructor of the class
023             * @param key
024             */
025            public CFCSetter(String key){
026                    this(KeyImpl.getInstance(key));
027            }
028            
029            /**
030             * Constructor of the class
031             * @param key
032             */
033            public CFCSetter(Collection.Key key){
034                    this.key=key;
035            }
036    
037            @Override
038            public String getMethodName() {
039                    return null;
040            }
041    
042            @Override
043            public Method getMethod() {
044                    return null;
045            }
046    
047            /**
048             * {@inheritDoc}
049             */
050            public void set(Object trg, Object value, SessionFactoryImplementor factory) throws HibernateException {
051                    try {
052                            Component cfc = Caster.toComponent(trg);
053                            cfc.getComponentScope().set(key,value);
054                    } 
055                    catch (PageException e) {
056                            throw new HibernateRuntimeException(e);
057                    }
058            }
059    
060    }