I recently discovered the convenience of using Refit, but after reading through its documentation I was unable to find a way to replace/override an implementation of an interface method that RestService would normally generate.
Does Refit provide a way to do this? Or is there a way to solve such a problem without getting too hacky?
I'm just worried about using Refit all over the place and then half way into a project realizing I can't modify the implementation of a method. It's inevitable that I'll have to break coding standards to meet a requirement and I'd like to know what would be the solution if a situation like this occurs?
Its not exectly what you want, but you can create extension where you call Refit implementation, but before and after call you can add any customization you want.
For example, I have use it to reformat response.
Related
Does anyone know or have implemented a basic framework in Jmeter which helps achieve re-usability and robustness.
I currently have 4 API's (upload file, get details, update file, delete file)
Now i need to test this for different formats.
I initially took the approach of putting all 4 api's in a thread group and disabling that group.
Then i called each api's using a module controller for different formats of the file.
This helped me achieve reusability but then asserting responses and extracting response using regex. extractor, became difficult and next to impossible.
Is there a way to achieve reusability in Jmeter? Module Controller works but it doesn't allow regex extractor which can inturn be used for assertion.
Instead of adding multiple assertions and regex extractors in every HTTP call, i would like to add it once and then probably reuse it.
I faced similar issues while implementing complex functional tests for a large web application. I used components mentioned below to achieve reusability:
Module Controller
Parameterized Controller
Loop Controller
IF controller
Beanshell & JMeter functions
You should not face any issue with use of Regex extractor under any controller. For conditioning you can use IF controller and Beanshell.
Parameterized controller is extremely useful if you need to use same samplers but with different datasets/values.
I would like to know what is the best way in which I can extend an existing functionality (probably by using AOP or Annotations). The scenario which I am looking for is.
We have one service say DisableEmployee which uses an entity Employee which does some validation and then disables access to employee.
For certain customers I would like to extend this functionality where DisableEmployee not only disables the access but also imposes some penalty points.
One approach would be I extend the base class and then add the additional functionality.
Is it possible (or advisable) to use AOP and annotations here; where in I annotate my DisableEmployee and then at compile time I weave the additional code into the class. (using aspect) I have read about APT and Velocity which should be able to help me in achieving it.
The reason I am looking at APT because we might have to extend the entity classes also to add some new attributes.
The idea of having this approach is to see if we can classify service extension as a form of cross-cutting functionality (like traditional logging, auditing ....)
Thanks in advance
Your question is too general to get reliable answer. But at the moment I cannot see anything what cannot be implemented in AspectJ.
I recently read about Dynamic Creation as one of the design pattern in Cocoa. However, I don't really understand how it works. So I need clarification from you who have implemented in your design.
What is it? Why and when would you use this design pattern?
I have read that you use NSClassFromString() to access the class. I assume that I use this when I want to use class that doesn't exist within the project I'm working on. Usually when I want to use certain class, I imported them in header. Does using this approach skip the #import process?
Class JavaArrayList = NSClassFromString(#"java.util.ArrayList");
I quote the code above as example. If do according to the code above, that means I can create a new JavaArrayList class and use the methods in it right?
JavaArrayList *foo = [[JavaArrayList alloc] init];
[foo useMethodBelongJava:doWhateverTask];
What are the benefits of using this design pattern? Especially in iPhone Development.
Your example appears to be using that pattern to instantiate a Java class. In the old days (up to about MacOS 10.4 I think), Apple had some technology called the Cocoa-Java Bridge, which let you use Java classes within Objective-C code. You had to instantiate them in the manner specified, because they didn't have Objective-C header files to import.
However, as of Snow Leopard, the Java Bridge no longer exists, so the code in your question won't work any more.
The recommended solution for calling a Java class from Objective-C is now JNI. Take a look at this question if that is what you're trying to do.
What is it? Why and when would you use this design pattern?
Coming back to NSClassFromString, it has other uses besides instantiating Java classes (which, as I mentioned, it doesn't do any more!). For an example, recently I wrote a library for parsing the response from a web service. In order to make it work with different web services, I had it read in a configuration file that described the data format it was expecting. For each field in the web service, my configuration file specified which Cocoa class to instantiate. Thus, in my code, I had a Cocoa class name as a string. To instantiate the object I wanted, I used NSClassFromString to turn it into a Class object.
Usually when I want to use certain class, I imported them in header. Does using this approach skip the #import process?
It can do. NSClassFromString will instantiate any class that is present at run time, so you don't need the header to be able to use it. If you don't have the header, you'll get a bunch of warnings of "may not respond to selector" whenever you try and use your newly instantiated class, as the compiler doesn't have enough information to be helpful. However, in many circumstances where NSClassFromString is useful, the header files aren't available.
See this link:
need advise about NSClassFromString
The only real benefit for iPhone was being able to reference classes from newer APIs and still target the old APIs. Since 4.0 you can do this anyway by setting the deployment target of your project. I can't really see any reason you would use it for iPhone programming any more.
This would only work for objective-C classes. You can't import java objects into your iphone app.
#BeanProperty generates simple get/set methods. Is there a way to automatically generate such methods with support for firing property change events (e.g. I want to use it with JFace Databinding?)
I've had the same question, and have been keeping a close eye out for possible answers. I think I've just stumbled across one (although I haven't tried it yet). Scala 2.9 has a feature for handling dynamic calls (meant for integration with dynamic languages, I suspect). Essentially, calls to methods which don't exist are routed to a method called applyDynamic. An implementation of that method could use reflection to check that the method signature matches a property (possibly one with an annotation similar to #BeanProperty). If there is a match, it could handle firing the event.
Maybe that's something where a custom compiler plugin can do the trick.
Sadly I have no idea about how to write such a plugin. But at least thought I give you this pointer.
I would be very interested, if you'd come up with something along that line.
I have the following bit of registration code:
Component.For<IPublishingService>().ImplementedBy<UseStoredProcedureToPrintService>(),
Component.For<IConfirmationDialog<AutomatedTransaction>>().ImplementedBy<ShipmentConfirmationDialog>().Named("ShipmentConfirmationDialog"),
Component.For<IConfirmationService<AutomatedTransaction>>().ImplementedBy<SingleTransactionConfirmation>().ServiceOverrides(
ServiceOverride.ForKey("shipmentDialog").Eq("ShipmentConfirmationDialog") ),
A requirement came down the line that in some instances the application is supposed to behave somewhat differently. Great I thought, this is exactly what I was using Castle Windsor for to begin with.
So I wrote my new components and I register them first. For example, I implement IPublishingService differently and register the new implementation first so that it is resolved over the default one above. However, a problem occurrs in the few cases where I had no choice but to use an id to wire up my service overrides. For example how do I redirect the ServiceOverride for ShipmentConfirmationDialog to use my new SpecialCaseShipmentConfirmationDialog implementation without modifying the bit of code above?
There are all sorts of mechanisms in castle windsor that I don't really understand like forwarding and ActAs that I'm hoping will provide a simple answer.
I'd keep it simple. If it's configurable, put it in the config (web.config / app.config) then just load the ID using ConfigurationManager.AppSettings["shipmentDialogToUse"];
Also remember that the fluent registration API is not the be-all and end-all of registration. XML still has its time and place where it's the right tool for the job.