Skip to content

Commit

Permalink
not yet functional switch from gwt-ent to xapi reflection
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Käfer committed Nov 3, 2015
1 parent 41fd798 commit ace5701
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 48 deletions.
1 change: 1 addition & 0 deletions atom-client/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
2 changes: 1 addition & 1 deletion atom-client/gwt dev mode inline.launch
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="com.google.gdt.eclipse.maven.mavenClasspathProvider"/>
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.google.gwt.dev.DevMode"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-war /home/kaefert/Development/workspace_ATOM/atom/atom-server/target/ATOM -startupUrl https://127.0.0.1:8843 -noserver -remoteUI &quot;${gwt_remote_ui_server_port}:${unique_id}&quot; -logLevel INFO -codeServerPort 9997 at.ac.fhcampuswien.atom.App"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-nosuperDevMode -war /home/kaefert/Development/workspace_ATOM/atom/atom-server/target/ATOM -startupUrl https://127.0.0.1:8843 -noserver -remoteUI &quot;${gwt_remote_ui_server_port}:${unique_id}&quot; -logLevel INFO -codeServerPort 9997 at.ac.fhcampuswien.atom.App"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="atom-client"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx512m"/>
</launchConfiguration>
20 changes: 10 additions & 10 deletions atom-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@

<!-- GWT client side APIs -->
<dependency>
<groupId>com.google.gwt</groupId>
<groupId>${gwt.groupid}</groupId>
<artifactId>gwt-user</artifactId>
<scope>provided</scope>
<version>${gwt.version}</version>
</dependency>

<!-- <dependency>
<dependency>
<groupId>net.wetheinter</groupId>
<artifactId>xapi-gwt-reflect</artifactId>
<version>0.5-SNAPSHOT</version>
<artifactId>xapi-gwt</artifactId>
<version>0.5</version>
<scope>provided</scope>
</dependency> -->
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
Expand Down Expand Up @@ -105,24 +105,24 @@
<plugins>
<!-- controling gwt-compile & css interface generation -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<groupId>${gwt.mavenplugin.groupid}</groupId>
<artifactId>gwt-maven-plugin</artifactId>

<!-- manually specify the GWT dependencies, so that we can choose gwt and gwt-maven-plugin versions independently of each other -->
<version>${gwt.mavenplugin.version}</version>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<groupId>${gwt.groupid}</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwt.version}</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<groupId>${gwt.groupid}</groupId>
<artifactId>gwt-dev</artifactId>
<version>${gwt.version}</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<groupId>${gwt.groupid}</groupId>
<artifactId>gwt-codeserver</artifactId>
<version>${gwt.version}</version>
</dependency>
Expand All @@ -144,7 +144,7 @@
<!-- <extraJvmArgs>-Xmx4096M -Xms1024M -XX:PermSize=128m -XX:MaxPermSize=256m</extraJvmArgs> -->
<!-- <extraJvmArgs>-Xmx1024M -Xms1024m -Xss32m -XX:PermSize=64m -XX:MaxPermSize=128m -XX:+UseCompressedOops -XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled -DgeneratePom=true -XX:ReservedCodeCacheSize=128m -XX:+PrintCompilation -server</extraJvmArgs> -->

<sourceLevel>1.7</sourceLevel>
<sourceLevel>1.8</sourceLevel>
<deploy>${project.build.directory}/gwtc/extra</deploy>
<extra>${project.build.directory}/gwtc/extra</extra>
<gen>${project.build.directory}/gwtc/gen</gen>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@
*/
package at.ac.fhcampuswien.atom.client;

import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;

import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.event.dom.client.KeyPressEvent;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.reflect.client.ConstPool;
import com.google.gwt.reflect.shared.GwtReflect;

import at.ac.fhcampuswien.atom.client.gui.attributes.components.FilterSpecificationDialogBox;
import at.ac.fhcampuswien.atom.client.rpc.RPCCaller;
import at.ac.fhcampuswien.atom.client.rpc.WaitingFor;
Expand All @@ -20,14 +28,6 @@
import at.ac.fhcampuswien.atom.shared.domain.DomainObject;
import at.ac.fhcampuswien.atom.shared.exceptions.ValidationError;

import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.event.dom.client.KeyPressEvent;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.gwtent.reflection.client.ClassType;
import com.gwtent.reflection.client.NotFoundException;
import com.gwtent.reflection.client.TypeOracle;

public class ClientTools {
private ClientTools() {
}
Expand All @@ -48,8 +48,11 @@ public static Object getAttributeValue(DomainClass domainClass, DomainClassAttri
// + ") started", null);

try {
ClassType<?> classType = TypeOracle.Instance.getClassType(domainClass.getName());
Object returnValue = classType.invoke(domainObject, "get" + AtomTools.upperFirstChar(domainClassAttribute.getName()), (Object[]) null);
Method getter = GwtReflect.getDeclaredMethod(getClassByName(domainClass.getName()), "get" + AtomTools.upperFirstChar(domainClassAttribute.getName()), new Class[] {});
Object returnValue = getter.invoke(domainObject, new Object[] {});

// ClassType<?> classType = TypeOracle.Instance.getClassType(domainClass.getName());
// Object returnValue = classType.invoke(domainObject, "get" + AtomTools.upperFirstChar(domainClassAttribute.getName()), (Object[]) null);
// AtomTools.log(Log.LOG_LEVEL_TRACE,
// "AtomTools.getAttributeValue successful", null);
// String stringValue;
Expand All @@ -60,7 +63,7 @@ public static Object getAttributeValue(DomainClass domainClass, DomainClassAttri
// AtomTools.log(Log.LOG_LEVEL_TRACE, "AtomTools.getAttributeValue(" + domainClass.getName() + ", " + domainClassAttribute.getName() + ", "
// + domainObject.getStringRepresentation() + ") found value '" + stringValue + "', returning", null);
return returnValue;
} catch (NotFoundException e) {
} catch (RuntimeException e) {
if (domainClass.getSuperClass() != null) {
AtomTools.log(Log.LOG_LEVEL_TRACE, "AtomTools.getAttributeValue(" + domainClass.getName() + ", " + domainClassAttribute.getName() + ", "
+ domainObject.getStringRepresentation() + ") did not find getMethod in this class, will try superclass", null);
Expand Down Expand Up @@ -94,9 +97,12 @@ public static void setAttributeValue(DomainClass domainClass, DomainClassAttribu
}

try {
ClassType<?> classType = TypeOracle.Instance.getClassType(domainClass.getName());
classType.invoke(domainObject, "set" + AtomTools.upperFirstChar(domainClassAttribute.getName()), new Object[] { value });
} catch (NotFoundException e) {
Method setter = GwtReflect.getDeclaredMethod(getClassByName(domainClass.getName()), "set" + AtomTools.upperFirstChar(domainClassAttribute.getName()), value.getClass());
setter.invoke(domainObject, value);

// ClassType<?> classType = TypeOracle.Instance.getClassType(domainClass.getName());
// classType.invoke(domainObject, "set" + AtomTools.upperFirstChar(domainClassAttribute.getName()), new Object[] { value });
} catch (RuntimeException e) {
if (domainClass.getSuperClass() != null) {
setAttributeValue(domainClass.getSuperClass(), domainClassAttribute, domainObject, value);
} else {
Expand Down Expand Up @@ -152,11 +158,31 @@ public static void validateDomainObject(DomainObject domainObject, DomainClass c
}
}


private static Class<? extends DomainObject> getClassByName(String className) {
Class<?> cls = ConstPool.getConstPool().getClassByName(className);
//Class<?> cls = Class.forName(domainClass.getName());

@SuppressWarnings("unchecked")
Class<? extends DomainObject> dcls = (Class<? extends DomainObject>) cls;

return dcls;
}

public static DomainObject createInstance(DomainClass domainClass) {
AtomTools.log(Log.LOG_LEVEL_DEBUG, "createInstance(" + domainClass.getName() + ")", null);
ClassType<?> classType = TypeOracle.Instance.getClassType(domainClass.getName());
String[] params = new String[] {};
return (DomainObject) classType.findConstructor(params).newInstance();

try {
return GwtReflect.construct(getClassByName(domainClass.getName()), new Class[] {}, new Object[] {});
} catch (Throwable e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}

//ClassType<?> classType = TypeOracle.Instance.getClassType(domainClass.getName());
// String[] params = new String[] {};
// return (DomainObject) classType.findConstructor(params).newInstance();
}

private static Map<Object, Date> recordedCalls = new HashMap<Object, Date>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@

<entry-point class="at.ac.fhcampuswien.atom.client.App" />

<inherits name='com.gwtent.GwtEnt' />
<!-- <inherits name='com.gwtent.GwtEnt' /> -->

<!-- <inherits name='com.google.gwt.reflect.Reflect' /> -->
<inherits name='com.google.gwt.reflect.Reflect' />
<!-- <inherits name='xapi.X_Reflect' /> -->

<inherits name='com.allen_sauer.gwt.dnd.gwt-dnd' />
Expand Down
13 changes: 7 additions & 6 deletions atom-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,15 @@
of this required annotation on @DomainObject it also needs to transverse
into the server side. Used in: at.ac.fhcampuswien.atom.client.ClientTools.getAttributeValue(..)
and setAttributeValue(..) -->
<dependency>
<!-- currently trying to replace this with net.wetheinter:xapi-gwt:0.5 -->
<!-- <dependency>
<type>jar</type>
<scope>compile</scope>
<groupId>gwtent</groupId>
<artifactId>gwtent</artifactId>
<version>2.0_RC1_GWT2.3</version>
<!-- <version>2.0_GWT2.2</version> -->
</dependency>
<version>2.0_GWT2.2</version>
</dependency> -->


<!--used for logging in method at.ac.fhcampuswien.atom.shared.AtomTools.log(..)
Expand Down Expand Up @@ -71,7 +72,7 @@
at.ac.fhcampuswien.atom.shared.dateformat depends on code from the gwt-user
package. It is used in AtomTools DateFormat constants -->
<dependency>
<groupId>com.google.gwt</groupId>
<groupId>net.wetheinter</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwt.version}</version>
<scope>provided</scope>
Expand Down Expand Up @@ -113,7 +114,7 @@
project that holds the normal RPC interface, which makes sense to have
in atom-core since both atom-client and atom-server need it. -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<groupId>${gwt.mavenplugin.groupid}</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${gwt.version}</version>
<executions>
Expand Down Expand Up @@ -158,7 +159,7 @@
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.codehaus.mojo
${gwt.mavenplugin.groupid}
</groupId>
<artifactId>
gwt-maven-plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;

import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.rpc.GwtTransient;

import at.ac.fhcampuswien.atom.shared.AtomConfig;
import at.ac.fhcampuswien.atom.shared.AtomTools;
import at.ac.fhcampuswien.atom.shared.ClientSession;
Expand All @@ -45,10 +48,6 @@
import at.ac.fhcampuswien.atom.shared.annotations.RelationDefinition;
import at.ac.fhcampuswien.atom.shared.annotations.RelationEssential;

import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.rpc.GwtTransient;
import com.gwtent.reflection.client.Reflectable;

/**
*
* @author thomas.kaefer
Expand Down Expand Up @@ -89,7 +88,7 @@
*/

//gwt-ent reflection, currently concidering to replace it with https://github.com/WeTheInternet/xapi/tree/master/gwt/gwt-reflect
@Reflectable(superClasses = false, assignableClasses = true, relationTypes = false, fields = false, methods = true, constructors = true, classAnnotations = false, fieldAnnotations = false)
//@Reflectable(superClasses = false, assignableClasses = true, relationTypes = false, fields = false, methods = true, constructors = true, classAnnotations = false, fieldAnnotations = false)

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
Expand Down
2 changes: 1 addition & 1 deletion atom-domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
which causes 'The hierarchy of the type * is incosistent' errors for all
DomainObject sub-classes if neither gwt-user nor gwt-servlet is present -->
<dependency>
<groupId>com.google.gwt</groupId>
<groupId>${gwt.groupid}</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwt.version}</version>
<scope>provided</scope>
Expand Down
4 changes: 2 additions & 2 deletions atom-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

<!-- GWT RPC framework -->
<dependency>
<groupId>com.google.gwt</groupId>
<groupId>${gwt.groupid}</groupId>
<artifactId>gwt-servlet</artifactId>
<version>${gwt.version}</version>
<scope>compile</scope>
Expand Down Expand Up @@ -138,7 +138,7 @@
</dependency>

<dependency>
<groupId>com.google.gwt</groupId>
<groupId>${gwt.groupid}</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwt.version}</version>
<scope>test</scope>
Expand Down
16 changes: 12 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<mavenVersion>3.0</mavenVersion>
<atom.version>1.0-SNAPSHOT</atom.version>
<java.version>1.7</java.version>
<java.version>1.8</java.version>

<!-- <gwt.version>[2.5.1,)</gwt.version> -->
<!-- <gwt.version>2.5.1</gwt.version>
Expand All @@ -33,11 +33,19 @@
(or the gwt.xml files which it includes) contains the following script tags: [INFO] gwtent/pagebus.js -->
<!-- sencha gxt - only works with 2.7.0, not with current trunk (or xapi gwt fork) -->

<gwt.version>2.6.1</gwt.version>
<gwt.mavenplugin.version>2.6.1</gwt.mavenplugin.version>
<!-- <gwt.version>2.6.1</gwt.version> -->
<!-- <gwt.mavenplugin.version>2.6.1</gwt.mavenplugin.version> -->

<!-- 2015-01-13: 2.7.0 = wont compile, errors from gwt-ent & sencha gxt! -->
<!-- <gwt.version>2.7.0</gwt.version> -->
<gwt.version>2.7.0</gwt.version>
<gwt.mavenplugin.version>2.7.0</gwt.mavenplugin.version>

<gwt.mavenplugin.groupid>net.wetheinter</gwt.mavenplugin.groupid>

<gwt.groupid>net.wetheinter</gwt.groupid>
<!-- default google group ids --> <!--
<gwt.groupid>com.google.gwt</gwt.groupid>
<gwt.mavenplugin.groupid>org.codehaus.mojo</gwt.mavenplugin.groupid> -->


<!-- with dia version 2015-07-02:
Expand Down

0 comments on commit ace5701

Please sign in to comment.