Search in sources :

Example 11 with Factory

use of net.sf.cglib.proxy.Factory in project powermock by powermock.

the class ProxyFrameworksTest method should_return_object_as_original_class_if_no_non_no_mocking_interfaces.

@Test
public void should_return_object_as_original_class_if_no_non_no_mocking_interfaces() {
    Factory someClass = (Factory) createCglibProxy(Factory.class);
    UnproxiedType unproxiedType = proxyFrameworks.getUnproxiedType(someClass);
    assertThatOriginalTypeInstanceOf(unproxiedType, Object.class);
}
Also used : Factory(net.sf.cglib.proxy.Factory) Test(org.junit.Test)

Example 12 with Factory

use of net.sf.cglib.proxy.Factory in project mybatis-3 by mybatis.

the class CglibProxyTest method shouldCreateAProxyForAPartiallyLoadedBean.

@Test
public void shouldCreateAProxyForAPartiallyLoadedBean() throws Exception {
    ResultLoaderMap loader = new ResultLoaderMap();
    loader.addLoader("id", null, null);
    Object proxy = proxyFactory.createProxy(author, loader, new Configuration(), new DefaultObjectFactory(), new ArrayList<Class<?>>(), new ArrayList<Object>());
    Author author2 = (Author) deserialize(serialize((Serializable) proxy));
    assertTrue(author2 instanceof Factory);
}
Also used : Configuration(org.apache.ibatis.session.Configuration) DefaultObjectFactory(org.apache.ibatis.reflection.factory.DefaultObjectFactory) Author(org.apache.ibatis.domain.blog.Author) CglibProxyFactory(org.apache.ibatis.executor.loader.cglib.CglibProxyFactory) Factory(net.sf.cglib.proxy.Factory) DefaultObjectFactory(org.apache.ibatis.reflection.factory.DefaultObjectFactory) Test(org.junit.Test)

Example 13 with Factory

use of net.sf.cglib.proxy.Factory in project CloudStack-archive by CloudStack-extras.

the class GenericDaoBase method createSearchCriteria2.

@Override
@DB(txn = false)
public <K> SearchCriteria2 createSearchCriteria2(Class<K> resultType) {
    final T entity = (T) _searchEnhancer.create();
    final Factory factory = (Factory) entity;
    SearchCriteria2 sc = new SearchCriteria2(entity, resultType, _allAttributes, this);
    factory.setCallback(0, sc);
    return sc;
}
Also used : Factory(net.sf.cglib.proxy.Factory) AttributeOverride(javax.persistence.AttributeOverride)

Example 14 with Factory

use of net.sf.cglib.proxy.Factory in project CloudStack-archive by CloudStack-extras.

the class GenericDaoBase method createSearchBuilder.

@Override
@SuppressWarnings("unchecked")
@DB(txn = false)
public <J> GenericSearchBuilder<T, J> createSearchBuilder(Class<J> resultType) {
    final T entity = (T) _searchEnhancer.create();
    final Factory factory = (Factory) entity;
    GenericSearchBuilder<T, J> builder = new GenericSearchBuilder<T, J>(entity, resultType, _allAttributes);
    factory.setCallback(0, builder);
    return builder;
}
Also used : Factory(net.sf.cglib.proxy.Factory) AttributeOverride(javax.persistence.AttributeOverride)

Example 15 with Factory

use of net.sf.cglib.proxy.Factory in project CloudStack-archive by CloudStack-extras.

the class GenericSearchBuilder method done.

/**
     * Marks the SearchBuilder as completed in building the search conditions.
     */
public synchronized void done() {
    if (_entity != null) {
        Factory factory = (Factory) _entity;
        factory.setCallback(0, null);
        _entity = null;
    }
    if (_joins != null) {
        for (JoinBuilder<GenericSearchBuilder<?, ?>> join : _joins.values()) {
            join.getT().done();
        }
    }
    if (_selects == null || _selects.size() == 0) {
        _selectType = SelectType.Entity;
        assert _entityBeanType.equals(_resultType) : "Expecting " + _entityBeanType + " because you didn't specify any selects but instead got " + _resultType;
        return;
    }
    for (Select select : _selects) {
        if (select.field == null) {
            assert (_selects.size() == 1) : "You didn't specify any fields to put the result in but you're specifying more than one select so where should I put the selects?";
            _selectType = SelectType.Single;
            return;
        }
        if (select.func != null) {
            _selectType = SelectType.Result;
            return;
        }
    }
    _selectType = SelectType.Fields;
}
Also used : Factory(net.sf.cglib.proxy.Factory)

Aggregations

Factory (net.sf.cglib.proxy.Factory)17 Test (org.junit.Test)5 AttributeOverride (javax.persistence.AttributeOverride)4 Method (java.lang.reflect.Method)2 Enhancer (net.sf.cglib.proxy.Enhancer)2 AmazonS3 (com.amazonaws.services.s3.AmazonS3)1 Attribute (com.amazonaws.services.simpledb.model.Attribute)1 DeleteAttributesRequest (com.amazonaws.services.simpledb.model.DeleteAttributesRequest)1 PutAttributesRequest (com.amazonaws.services.simpledb.model.PutAttributesRequest)1 ReplaceableAttribute (com.amazonaws.services.simpledb.model.ReplaceableAttribute)1 UpdateCondition (com.amazonaws.services.simpledb.model.UpdateCondition)1 Select (com.cloud.utils.db.GenericSearchBuilder.Select)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 AnnotationInfo (com.spaceprogram.simplejpa.AnnotationInfo)1 LazyInterceptor (com.spaceprogram.simplejpa.LazyInterceptor)1 PersistentProperty (com.spaceprogram.simplejpa.PersistentProperty)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1