Coder Social home page Coder Social logo

jjaram / chameleon Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 100 KB

Is a java framework that helps the copy objects that have the same attributes types, without the necessity to create heavy factories and deal with the creation of the subrelations objects.

Java 100.00%
jpa spring-aop spring-beans aspectjweaver java java-proxy javassist

chameleon's Introduction

chameleon's People

Contributors

jjaram avatar

Watchers

 avatar  avatar

chameleon's Issues

Create jpa adapter

Actually we have the hibernate logic linked in the principal project, we want to separate the logic to prevent create a big jar

public static ChameleonProxyAdapter getInstance(Field field, String fieldName, Object data) throws InstantiationException, IllegalAccessException, NoSuchFieldException {
     ChameleonProxyAdapter proxy = new DefaultProxyChameleon(field, fieldName, data);
     if (proxy.getValue() != null) {
          if (proxy.getValue() instanceof HibernateProxy ) {
               proxy = new HibernateProxyChameleon(proxy.getValue(), field);
          } else if (proxy.getValue() instanceof PersistentSet) {
               proxy = new PersistentSetProxy(proxy.getValue(), field);
          }
     }
     return proxy;
}

Maybe we want think in create and herency of classes using Adapter Pattern

Create proxy for repository

Actually when we want to create queries using @query we need to create a new class and add the annotation but in the body we need to return a null value as the example:

@Component
public class PlaceDTORepository {

    @Query("SELECT V.referenceId, V.name, P.referenceId, P.prefix, P.suffix, P.width, P.height FROM Place V JOIN Photos P")
    public Set<PlaceDTO> fetchNearPlacesByLocationName(Set<Place> source) {return null;}
}

So in the new solution we want to create queries in a interface, like SpringData.

Create reader of properties

We need to create a reader properties, because currently with the creation of the ticket #2 we set the ProxyVendorAdapter by default using hibernate.

public class ChameleonVendorAdapterStrategy {

    public static VendorProxyAdapter getInstance(Field field, String fieldName, Object data) throws InstantiationException, IllegalAccessException, NoSuchFieldException {
        VendorProxyAdapter proxy = new DefaultProxyChameleon(field, fieldName, data);
        if (proxy.getValue() != null) {
            try {
                Class<?> clazz = Class.forName("com.jjm.chameleon.support.proxy.jpa.HibernateVendorProxyAdapter");
                Constructor<?> constructor = clazz.getConstructor(Object.class, Field.class);
                proxy = (VendorProxyAdapter) constructor.newInstance(new Object[] { proxy.getValue(), field });
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (NoSuchMethodException e) {
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                e.printStackTrace();
            }
        }
        return proxy;
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.