From the Gradle's code I found that there are methods :
TemporaryFileProvider and TestNameTestDirectoryProvider for creating temporary file and folder but they are not part of the public API.
org.gradle.api.internal.file.TemporaryFileProvider
org.gradle.test.fixtures.file.TestNameTestDirectoryProvider
If there any methods from the public Gradle's API that gives the user ability to create temporary files and folders and if not what are the best ways to do it?
PS. I use org.junit.rules.TemporaryFolder for JUnit tests and Java's File.createTempFile
Task implementations can use task.getTemporaryDir().createNewFile(). What to use in JUnit tests isn't Gradle's business, but org.junit.rules.TemporaryFolder would be my default choice.
Related
I am using Dexguard to obfuscate my application, but i was wondering why it is not obfuscating the names of Activity classes.
Is there any way to obfuscates these names?
DexGuard won't obfuscate names of activity classes that are exported, because the Android runtime treats them as public API. See How to obfuscate a class which is referenced in Manifest file using Dexguard?.
I have file with functions which I want to use everywhere in my application.
In raw PHP the way to do it is to call them in each file by include or require.
Is there any simple way in Yii to call this file once and use it everywhere?
Second question is to call the same file and use it in a particular controller.
You can require this file in main config of your appllication for example, or in beforeAcition method of application base controller if you have it.
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'components/some_funcs.php';
maybe this could help you THE DEFINITIVE GUIDE TO YII.
Using 3rd-Party Libraries
Yii is carefully designed so that third-party libraries can be easily integrated to further extend Yii's functionalities. When using third-party libraries in a project, developers often encounter issues about class naming and file inclusion. Because all Yii classes are prefixed with letter C, it is less likely class naming issue would occur; and because Yii relies on SPL autoload to perform class file inclusion, it can play nicely with other libraries if they use the same autoloading feature or PHP include path to include class files.
Below we use an example to illustrate how to use the Zend_Search_Lucene component from the Zend framework in a Yii application.
First, we extract the Zend framework release file to a directory under protected/vendors, assuming protected is the application base directory. Verify that the file protected/vendors/Zend/Search/Lucene.php exists.
Second, at the beginning of a controller class file, insert the following lines:
Yii::import('application.vendors.*');
require_once('Zend/Search/Lucene.php');
Quartz.net and me don't seem to think the same way. Please help.
I'll have Quartz running as a Windows Service.
I'll have an Ado Jobstore setup on my SQL server.
I'll have the connection string setup that allows Quartz to access the jobstore.
I'll have a trigger job data map (stored in the jobstore?).
I see that I can set a Job-name, and can have Job Data Map key/value pairs that I can store for example a stored proc name and maybe a param. So far so good. I also see that I can write code that will implement iJob and in it grab the key/values from the context. My code could then call the stored proc with standard ADO code. I could do a similar thing with a webservice name and param, where my custom code would call the service.
Here are my questions:
1) Do I really have to create a separate piece of code to execute the stored proc or web service? I would think something as sophisticated as Quartz would be able to "natively" handle calls to stored procs, web services, maybe execute ftp commands, etc. Am I looking for a no-code solution when I shouldn't be?
2) Assuming I do have to write my own "do the work" code, where do I put that code? Do I compile into a DLL and place it somewhere? How do I tell Quartz where to look for my DLLs? And how do I associate the Job-Name in the config with my class in my DLL? Do I just use the Job-Name setting as the actual name of my class?
Thanks!
1) Yes, you still have to write separate job classes.
2) All your class has to do is implement the IJob interface and the scheduler will pick it up. Read the documentation.
Quartz is a scheduler, it's all it does and it does it well. It does not "natively" handle calls to stored procs, web services, or ftp commands. You have to write the code to do that in your class that implements IJob and is instantiated by Quartz on the schedule you specify.
The best thing to do is to create a separate class library (DLL) that you will reference from your app which creates an instance of Quartz scheduler and provide it with a fully qualified name of the class it needs to instantiate (e.g. MyLibrary.MyNameSpace.MyClass) and it will instantiate that class on the schedule and execute your code found in the overriden Execute() method of your class...
It's that simple...
As Google App Engine will start and stop instances regularly, and this means incurring the cold start time regularly, I'd like to configure my Spring MVC3 app using XML to avoid the 3-5 sec delay caused by scanning the class files for annotations when using annotation configuration when a new instance is spun up.
However writing the xml is a bit of a chore and much easier to use the annotations to define my configuration. So I'd like the best of both worlds and to use the annotations to generate the config file, and then turn off the scanning at runtime. From this question it seems there aren't any existing tools that will do this.
So what is the best way to approach this? Presumably there is a class which does the scanning in spring at runtime that could be re-appropriated to scan at design time and then spit out the xml?
Are there any limitations on things which can be done from the annotation configuration which will not be possible in the xml configuration?
I would do this using Spring for scanning the package that contains the annotated classes, then using reflection for getting the annotations on the class and its methods and writing the XML accordingly to them.
The class that does the scanning in Spring is ClassPathScanningCandidateComponentProvider. Here is a code snippet of how it can be used :
ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false);
scanner.addIncludeFilter(new AnnotationTypeFilter(Component.class));
for(String packageToScan : packagesToScan) {
for (BeanDefinition bd : scanner.findCandidateComponents(packageToScan)) {
Class clazz = Class.forName(bd.getBeanClassName());
// Use reflection on clazz to write the XML file
}
}
I hope this helps !
I'm using Prism in my WPF application and up to now, I've been loading the modules via var moduleCatalog = new ConfigurationModuleCatalog();. I'd like to get the module catalog from a database. The Prism documentation indicates that this is possible, but it doesn't go into any details.
Has anyone done this and can provide some guidance?
This is a theoretical possibility, but it's not in any samples I've seen.
Basically what you'd do is either base64 encode the DLLs / Files into the database or zip them up and store them in one blob. You'd download them in your bootstrapper and copy them locally (in a temp directory) and then allows them to load normally from the filesystem using the DirectoryModuleCatalog. If you wanted it to be a bit more elegant, you could write your own ModuleCatalog that encapsulates this logic.
This is very similar to what I do... I actually download a zip file of all of the modules from a website at launch time and unzip them and load them with the DirectoryModuleCatalog.
You can write your own ModuleCatalog implementation by implementing IModuleCatalog. Your implementation can then populate the catalog by any means you define.
You could also use the CreateFromXAML overload that accepts a Stream and implement a webservice that delivers the ModuleCatalog in XAML over HTTP.