Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
3b33792
Define new architecture
Jun 4, 2013
71db357
Implement EBeanHandler
yDelouis May 22, 2013
8c359bf
Implement EActivityHandler
Jun 4, 2013
f1b3eb5
Implement EApplicationHandler
yDelouis May 23, 2013
03620f9
Implement EFragmentHandler
yDelouis May 23, 2013
b57cd25
Implement EProviderHandler
yDelouis May 23, 2013
033807b
Implement EReceiverHandler
yDelouis May 23, 2013
02d42a6
Implement EServiceHandler
yDelouis May 23, 2013
a7f2993
Implement EViewHandler
yDelouis May 23, 2013
4caf816
Implement EViewGroupHandler
yDelouis May 23, 2013
b685ed4
Implement AfterInjectHandler
yDelouis May 23, 2013
b7fa477
Implement SharedPrefHandler
yDelouis May 23, 2013
0fdf190
Implement RoboGuiceHandler
yDelouis May 29, 2013
20d6da4
Implement PrefHandler
yDelouis May 29, 2013
ba5d5e3
Implement ViewByIdHandler
yDelouis May 29, 2013
84c38e1
Implement FragmentByIdHandler
yDelouis May 29, 2013
18a35ba
Implement FragmentByTagHandler
yDelouis May 30, 2013
d7126a3
Implement FromHtmlHandler
yDelouis May 30, 2013
6e7d28a
Implement ClickHandler
yDelouis May 30, 2013
9d0a9eb
Implement LongClickHandler
yDelouis May 30, 2013
3f0f7e1
Implement TouchHandler
yDelouis May 30, 2013
7fd8a68
Implement FocusChangeHandler
yDelouis May 30, 2013
c3f8031
Implement CheckedChangeHandler
yDelouis May 30, 2013
90f9474
Implement ItemClickHandler
yDelouis May 30, 2013
0ff7b93
Implement ItemSelectHandler
yDelouis May 30, 2013
a37c6b2
Implement ItemLongClickHandler
yDelouis May 30, 2013
29c0e84
Implement ResHandler
yDelouis May 31, 2013
18aaf83
Implement TransactionalHandler
yDelouis May 31, 2013
ffb7bd1
Implement ExtraHandler
yDelouis May 31, 2013
ec481d7
Implement FragmentArgHandler
yDelouis May 31, 2013
b822da4
Implement SystemServiceHandler
yDelouis May 31, 2013
26ac5e8
Implement InstanceStateHandler
Jun 2, 2013
a49f68c
Implement RestHandler
yDelouis Jun 3, 2013
2c20fec
Implement RestMethodHandler (abstract)
yDelouis Jun 3, 2013
6667c42
Implement GetHandler
yDelouis Jun 3, 2013
be221e6
Implement PostHandler
yDelouis Jun 3, 2013
d6a646e
Implement PutHandler
yDelouis Jun 3, 2013
1ca9dcc
Implement DeleteHandler
yDelouis Jun 3, 2013
75513cc
Implement HeadHandler
yDelouis Jun 3, 2013
1cad379
Implement OptionsHandler
yDelouis Jun 3, 2013
d8af1f4
Implement AppHandler
yDelouis Jun 3, 2013
459dee7
Implement OptionsMenuHandler
yDelouis Jun 3, 2013
665f185
Implement OptionsMenuItemHandler
yDelouis Jun 3, 2013
fb11534
Implement OptionsItemHandler
yDelouis Jun 3, 2013
663b944
Implement NoTitleHandler
Jun 3, 2013
7b5f76a
Implement CustomTitleHandler
Jun 4, 2013
2c02824
Implement FullscreenHandler
Jun 4, 2013
6061fff
Implement RestServiceHandler
Jun 4, 2013
908c44b
Implement OrmLiteDaoHandler
yDelouis Jun 5, 2013
f38accd
Implement RootContextHandler
yDelouis Jun 5, 2013
7dd74db
Implement NonConfigurationInstanceHandler
yDelouis Jun 5, 2013
4ec69c9
Implement BeanHandler
yDelouis Jun 5, 2013
d208897
Refactor EComponentHolder with View support
yDelouis Jun 5, 2013
ba173b9
Implement BeforeTextChangeHandler
yDelouis Jun 6, 2013
3c94932
Implement TextChangeHandler
yDelouis Jun 6, 2013
3bf319d
Implement AfterTextChangeHandler
yDelouis Jun 6, 2013
140be6a
Implement SeekBarProgressChangeHandler
yDelouis Jun 6, 2013
d5a7524
Implement SeekBarTouch(Start & Stop)Handler
yDelouis Jun 6, 2013
d9c0250
Implement AfterViewsHandler
yDelouis Jun 6, 2013
10969cd
Implement TraceHandler
yDelouis Jun 6, 2013
f5bb517
Implement SubscribeHandler
yDelouis Jun 6, 2013
219f72b
Implement ProduceHandler
yDelouis Jun 6, 2013
5853e5a
Implement UiThreadHandler
yDelouis Jun 6, 2013
5218a5e
Implement BackgroundHandler
yDelouis Jun 6, 2013
95b7568
Implement HttpsClientHandler
yDelouis Jun 6, 2013
cea95c2
Implement OnActivityResultHandler
yDelouis Jun 6, 2013
13b13bf
Implement HierarchyViewerSupportHandler
yDelouis Jun 6, 2013
5c698d8
Implement WindowFeatureHandler
yDelouis Jun 6, 2013
f214ddd
Remove unused classes and clean
yDelouis Jun 6, 2013
3d0292f
Make onCreate accessible for tests
yDelouis Jun 6, 2013
ae63ccf
Add getInitBody method
yDelouis Jun 6, 2013
91914dd
Remove useless test about no rebinding singleton
yDelouis Jun 6, 2013
bced1c8
Handle bug with byte[] in extras
yDelouis Jun 6, 2013
22fd1b6
Add license
yDelouis Jun 6, 2013
94acf91
Format and organise import with eclipse
yDelouis Jun 10, 2013
5bc3db9
Merge merged PR 609 : specify package of R class
yDelouis Jun 10, 2013
fb4676a
Merge PR 569 : Cancel background tasks
yDelouis Jun 10, 2013
3dc48f2
Merge merged PR 624 : Fix cancel background tasks
yDelouis Jun 10, 2013
3fdc190
Make validation inheritance easier
yDelouis Jun 13, 2013
9931679
Make AnnotationHandler aware of the ProcessHolder
yDelouis Jun 13, 2013
b294662
Merge merged PR 629 : Handle RuntimeExceptionDao
yDelouis Jun 17, 2013
6c8d9df
Merge merged PR 627 : Generic type in @ItemClick
yDelouis Jun 18, 2013
642abb0
Merge merged PR 637 : Trigger annotations
yDelouis Jun 20, 2013
6dc7a83
Fix bad generated code by FullscreenHandler
yDelouis Jul 2, 2013
0414900
Fix missing setContentView in activities
yDelouis Jul 2, 2013
5421392
Merge merged PR 605 and 655 : Check current thread
yDelouis Jul 15, 2013
cdeac84
Merge merged PR 579 : Rest Authentication
yDelouis Jul 15, 2013
3e48a08
Merge merged PR 657 : Update to ADT 22
yDelouis Jul 15, 2013
0376f27
Merge merged PR 654 : Move some API classes
yDelouis Jul 15, 2013
498daa9
Fix non null HttpEntity in Rest requests
yDelouis Jul 15, 2013
4788b47
Merge merged PR 658 : EnhancedRestClient interfaces
yDelouis Jul 16, 2013
bf9eb34
Merge merged PR 677 : Propagate thread exceptions
yDelouis Nov 26, 2013
9d5bf79
Merge merged PR 678 : Warning on null root context
yDelouis Nov 26, 2013
612bb45
Merge merged PR 682 : Propagate thread exceptions
yDelouis Nov 26, 2013
7b4bd09
Merge merged PR 702 : Fix typo
yDelouis Nov 26, 2013
69e9a10
Merge merged PR 694 : Handler in main thread
yDelouis Nov 27, 2013
246c14e
Merge merged PR 680 : Fragment start activity for result
yDelouis Nov 27, 2013
46d3f6b
Merge merged PR 710 : Inject ClipboardManager
yDelouis Nov 27, 2013
367d60a
Merge merged PR 618 : Enhance crash report
yDelouis Dec 2, 2013
96c82d3
Merge merged PR 617 : ResId null pointer
yDelouis Dec 3, 2013
1c95d7e
Merge merged PR 601 : Enhanced IntentService
yDelouis Dec 8, 2013
576e8b6
Merge merged PR 729 : Fix tests
yDelouis Dec 8, 2013
cce0a2c
Add missing licenses
yDelouis Dec 8, 2013
d9ce667
Merge merged PR 733 : Fix extra
yDelouis Dec 9, 2013
034eeaf
Merge merged PR 734 : Check API version
yDelouis Dec 9, 2013
f3c9179
Merge merged PR 735 : Small typo
yDelouis Dec 9, 2013
c5bdca0
Merge merged PR 737 : Fix API properties loading
yDelouis Dec 9, 2013
5ef89f4
Merge merged PR 740 : Fix exception
yDelouis Dec 9, 2013
a53eabc
Merge merged PR 736 : Fix @Touch
yDelouis Dec 9, 2013
b3ca678
Merge branch from deathlord87 : Put and Delete return
yDelouis Dec 9, 2013
534a825
Merge branch from dhleong : Add missing rest authentication
yDelouis Dec 9, 2013
3a774f6
Merge merged PR 763 : Send background exception to UncaughtExceptionH…
yDelouis Dec 9, 2013
90b2e4c
Merge commit 51f31e1 : Fix NPE on version checking
yDelouis Dec 9, 2013
53840c7
Merge merged PR 772 : No fragment on Froyo
yDelouis Dec 9, 2013
fb9d0f5
Merge merged PR 785 : Ignore Internet permission in library
yDelouis Dec 9, 2013
3c1738c
Merge merged PR 786 : HoloEverywhere uses ABS
yDelouis Dec 9, 2013
dd03a8c
Merge merged PR 792 : Singleton circular reference
yDelouis Dec 9, 2013
575b20e
Merge merged PR 800 : Fix ThreadActivityTest
yDelouis Dec 9, 2013
f9056d6
Fix log not done inside runnable for @Background and @UIThread
yDelouis Dec 10, 2013
516cb96
Fix missing return statement in onHandleIntent()
yDelouis Dec 10, 2013
1bed539
Fix bad request entity in rest methods
yDelouis Dec 10, 2013
ea91f41
Fix onStop and onDestroy called twice with RoboGuice
yDelouis Dec 10, 2013
fa7fd13
Add missing licenses
yDelouis Dec 11, 2013
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge merged PR 658 : EnhancedRestClient interfaces
  • Loading branch information
yDelouis committed Jul 16, 2013
commit 4788b47225d2438787df1f4ba326841301bca624
7 changes: 7 additions & 0 deletions AndroidAnnotations/androidannotations-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
<version>1.6_r2</version>
<scope>provided</scope>
</dependency>
<dependency>
<!-- spring-android-rest-template is required to use the Rest API -->
<groupId>org.springframework.android</groupId>
<artifactId>spring-android-rest-template</artifactId>
<version>1.0.0.RELEASE</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Copyright (C) 2010-2013 eBusiness Information, Excilys Group
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.androidannotations.api.rest;

/**
* A @Rest interface implementing this interface will automatically have the
* implementations of this method generated.
*/
public interface RestClientErrorHandling {
/**
* Sets the error handler called when a rest error occurs.
*
* @param handler
*/
void setRestErrorHandler(RestErrorHandler handler);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/**
* Copyright (C) 2010-2013 eBusiness Information, Excilys Group
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.androidannotations.api.rest;

import org.springframework.http.HttpAuthentication;

/**
* A @Rest interface implementing this interface will automatically have the
* implementations of these methods generated.
*/
public interface RestClientHeaders {

/**
* Gets a cookie by name.
*
* @param name
* @return the cookie value.
*/
String getCookie(String name);

/**
* Sets a cookie by name.
*
* @param name
* @param value
*/
void setCookie(String name, String value);

/**
* Gets a header by name.
*
* @param name
* @return the header value.
*/
String getHeader(String name);

/**
* Sets a header by name.
*
* @param name
* @param value
*/
void setHeader(String name, String value);

/**
* Sets the authentication object.
*
* @param auth
*/
void setAuthentication(HttpAuthentication auth);

/**
* Sets the basic authentication user/password.
*
* @param user
* @param password
*/
void setHttpBasicAuth(String user, String password);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Copyright (C) 2010-2013 eBusiness Information, Excilys Group
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.androidannotations.api.rest;

/**
* A @Rest interface implementing this interface will automatically have the
* implementations of these methods generated.
*/
public interface RestClientRootUrl {
/**
* Gets the root URL for the rest service.
*
* @return String
*/
String getRootUrl();

/**
* Sets the root URL for the rest service.
*
* @param rootUrl
*/
void setRootUrl(String rootUrl);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Copyright (C) 2010-2013 eBusiness Information, Excilys Group
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.androidannotations.api.rest;

import org.springframework.web.client.RestTemplate;

/**
* A @Rest interface implementing this interface will automatically have the
* implementations of these methods generated.
*/
public interface RestClientSupport {
/**
* Gets the rest template used by the rest service implementation.
*
* @return RestTemplate
*/
RestTemplate getRestTemplate();

/**
* Sets the rest template used by the rest service implementation.
*
* @param rt
*/
void setRestTemplate(RestTemplate rt);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Copyright (C) 2010-2013 eBusiness Information, Excilys Group
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.androidannotations.api.rest;

import org.springframework.web.client.RestClientException;

/**
* This interface is used for handling rest client exceptions.
*/
public interface RestErrorHandler {
/**
* Called when an exception occurs within the rest client.
*
* @param e
*/
void onRestClientExceptionThrown(RestClientException e);
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void validate(Element element, AnnotationElements validatedElements, IsVa

validatorHelper.isTopLevel(typeElement, valid);

validatorHelper.doesNotExtendOtherInterfaces(typeElement, valid);
validatorHelper.doesNotExtendInvalidInterfaces(typeElement, valid);

validatorHelper.unannotatedMethodReturnsRestTemplate(typeElement, valid);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ public void process(Element element, RestHolder holder) {
}

if (methodReturnVoid && result == null) {
methodBody.add(exchangeCall);
insertRestTryCatchBlock(holder, methodBody, exchangeCall, methodReturnVoid);
} else if (!methodReturnVoid) {
returnCall = addResultCallMethod(returnCall, methodReturnClass);
methodBody._return(returnCall);
insertRestTryCatchBlock(holder, methodBody, returnCall, methodReturnVoid);
}
}

Expand Down Expand Up @@ -195,4 +195,41 @@ private JFieldRef setCookies(ExecutableElement executableElement, RestHolder res
}
return null;
}

/**
* Adds the try/catch around the rest execution code.
*
* If an exception is caught, it will first check if the handler is set. If
* the handler is set, it will call the handler and return null (or nothing
* if void). If the handler isn't set, it will re-throw the exception so
* that it behaves as it did previous to this feature.
*/
private void insertRestTryCatchBlock(RestHolder holder, JBlock body, JExpression returnCall, boolean methodReturnVoid) {
JTryBlock tryBlock = body._try();

if (methodReturnVoid) {
tryBlock.body().add((JInvocation) returnCall);
} else {
tryBlock.body()._return(returnCall);
}

JCatchBlock jCatch = tryBlock._catch(classes().REST_CLIENT_EXCEPTION);

JBlock catchBlock = jCatch.body();
JConditional conditional = catchBlock._if(JOp.ne(holder.getRestErrorHandlerField(), JExpr._null()));
JVar exceptionParam = jCatch.param("e");

JBlock thenBlock = conditional._then();

// call the handler method if it was set.
thenBlock.add(holder.getRestErrorHandlerField().invoke("onRestClientExceptionThrown").arg(exceptionParam));

// return null if exception was caught and handled.
if (!methodReturnVoid) {
thenBlock._return(JExpr._null());
}

// re-throw the exception if handler wasn't set.
conditional._else()._throw(exceptionParam);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
import java.util.ArrayList;
import java.util.List;

import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.type.ArrayType;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.type.WildcardType;
import javax.lang.model.type.*;
import javax.lang.model.util.ElementFilter;

import org.androidannotations.holder.EComponentHolder;
import org.androidannotations.holder.GeneratedClassHolder;
Expand Down Expand Up @@ -246,4 +246,84 @@ public JDefinedClass createDelegatingAnonymousRunnableClass(EComponentHolder hol

return anonymousRunnableClass;
}

/**
* Gets all of the methods of the class and includes the methods of any
* implemented interfaces.
*
* @param typeElement
* @return full list of methods.
*/
public List<ExecutableElement> getMethods(TypeElement typeElement) {
List<? extends Element> enclosedElements = typeElement.getEnclosedElements();
List<ExecutableElement> methods = new ArrayList<ExecutableElement>(ElementFilter.methodsIn(enclosedElements));

// Add methods of the interfaces. These will be valid as they have gone
// through the validator.
for (TypeMirror iface : typeElement.getInterfaces()) {
DeclaredType dt = (DeclaredType) iface;
methods.addAll(ElementFilter.methodsIn(dt.asElement().getEnclosedElements()));
}

return methods;
}

public JMethod implementMethod(GeneratedClassHolder holder, List<ExecutableElement> methods, String methodName, String returnType, String... parameterTypes) {
// First get the ExecutableElement method object from the util function.
ExecutableElement method = getMethod(methods, methodName, returnType, parameterTypes);
JMethod jmethod = null;

if (method != null) {
// Get the return type or VOID if none.
JType jcReturnType = returnType.equals(TypeKind.VOID.toString()) ? holder.codeModel().VOID : holder.refClass(returnType);

// Create the implementation and annotate it with the Override
// annotation.
jmethod = holder.getGeneratedClass().method(JMod.PUBLIC, jcReturnType, method.getSimpleName().toString());
jmethod.annotate(Override.class);

// Create the parameters.
for (int i = 0; i < method.getParameters().size(); i++) {
VariableElement param = method.getParameters().get(i);
jmethod.param(holder.refClass(parameterTypes[i]), param.getSimpleName().toString());
}
}

return jmethod;
}

private ExecutableElement getMethod(List<ExecutableElement> methods, String methodName, String returnType, String... parameterTypes) {
for (ExecutableElement method : methods) {
List<? extends VariableElement> parameters = method.getParameters();

// Get the method return type or "VOID" if none.
String methodReturnType = method.getReturnType().getKind() == TypeKind.VOID ? TypeKind.VOID.toString() : method.getReturnType().toString();

if (parameters.size() == parameterTypes.length && methodReturnType.equals(returnType)) {
if (methodName == null || method.getSimpleName().toString().equals(methodName)) {
// At this point, method name, return type and number of
// parameters are correct. Now we need to validate the
// parameter types.
boolean validMethod = true;

for (int i = 0; i < parameters.size(); i++) {
VariableElement param = parameters.get(i);

if (!param.asType().toString().equals(parameterTypes[i])) {
// Parameter type does not match, this is not the
// correct method.
validMethod = false;
break;
}
}

if (validMethod) {
return method;
}
}
}
}

return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public final class CanonicalNameConstants {
public static final String CLIENT_HTTP_REQUEST_INTERCEPTOR = "org.springframework.http.client.ClientHttpRequestInterceptor";
public static final String HTTP_AUTHENTICATION = "org.springframework.http.HttpAuthentication";
public static final String HTTP_BASIC_AUTHENTICATION = "org.springframework.http.HttpBasicAuthentication";
public static final String REST_CLIENT_EXCEPTION = "org.springframework.web.client.RestClientException";

/*
* RoboGuice
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.