w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Write-behind caching solution for Java objects, using oracle stored procs for persistence
What I have done in the past in this situation is to write the data to Java Chronicle and have this forwarded to a database in another thread or process. Java Chronicle supports low latency persisted IPC. You can persist objects at a rate of over one million per second with sub-micro-second latencies. The reading process can pick up those objects/events with in 100 nano-seconds. As you have to do the JDBC part yourself, you do this any manner you choose.

Categories : Java

Estructuration of multi module project. how to packaging modules?
Ok, first question, i put all the dependencies at paren's pom is this really correct? No, your shared dependencies should be put in the ear pom. In the other poms you have to reference the shared dependencies using <scope>provided</scope>. For example in your ear pom add a dipendency: <dependency> <groupId>somegroup</groupId> <artifactId>someartifact</artifactId> <version>1.0</version> </dependency> In the logica and ui module pom, for example, add these lines: <dependency> <groupId>somegroup</groupId> <artifactId>someartifact</artifactId> <version>1.0</version> <scope>provided</scope> </dependency> In this way the dependency arti

Categories : Maven

Maven multi-modules by features but sharing webapp
Thinking about this, the best advice I have for you is: deploy separately what a separate team builds. If these sub-systems really need to be independent from each other, and can be released independently it makes no sense at all to deploy them together all at once. If that is not possible because of the requirements of your system, the best solution in terms of architecture would be to combine the front-end layer in one WAR component, which is dependent on the different business-sub-systems (domain, dao and service). The teams need to share this component but can separate their work across e.g. different folders or packages. Having said this, life in consulting is often not that easy that logical solutions are possible just like that. So here is my more down-to-earth answer: In the m

Categories : Maven

IDE where compile-on-save works in a multi modules maven project
This is how it works in IntelliJ with a maven multi module project. Structure: . ├── pom.xml ├── module-1 | ├── pom.xml | └── src | └── main | └── java | └── com | └── stackoverflow | └── foo | └── Foo.java └── module-2 ├── pom.xml └── src └── main └── java └── com └── stackoverflow └── bar └── Bar.java Bar extends Foo so module-2 has a dependency on module-1. pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/

Categories : Eclipse

build a org.eclipse.persistence.queries.ReportQuery from a javax.persistence.Query
How are you executing the ReportQuery? You need to call Session.executeQuery(query, arguments) and pass a List of the arguments (order the same as query.getArguments(). You can probably also use the JpaEntityManager createQuery(DatabaseQuery) API to convert the ReportQuery back to a JPA Query, then you can just set the parameter the JPA way.

Categories : Java

NullPointerException: Unable to create the container entity manager factory for the org.jbpm.persistence.jpa persistence unit
I was able to fix this error by setting hibernate.temp.use_jdbc_metadata_defaults to false. I'm not sure from the excerpts you posted where you would set it. For me it was the Spring config of the persistence unit.

Categories : Xml

Maven multi module project build: modules in local repo
The answer is no. Here are the maven lifecycle phases As you can see, package comes before install, so install wont be executed - nothing will go to your local repo, unless it was there already.

Categories : Maven

Sonar Analysis - Component version in Maven multi modules context
If the modules have a different version scheme than their parent, may be this means that they should be independent, don't you think? (what's the point of having coupled-lifecycle components if they don't follow the same versions?) And in turn, they should be built and analysed separately.

Categories : Maven

Error creating bean with name 'entityManagerFactory' -> Cannot parse persistence unit from class path resource [META-INF/persistence.xml]
Firstly, java compiler will not validate the existence of persistence.xml during compile time. The error only happen at runtime. Stack trace you're getting is pretty clear, your program could not locate persistence.xml on classpath. The location of persistence.xml within your jar has to be: META-INF/persistence.xml, or if it's war: WEB-INF/classes/META-INF/persistence.xml

Categories : Java

how to use shared preference on multi textview,multi checkbox,multi button and multi edit box in android?
Use these method to save and get values from any where in your app change parameter according to your requirment this method to save value in shared prefrences public static void setPref(Context c, String pref, String val) { Editor e = PreferenceManager.getDefaultSharedPreferences(c).edit(); e.putString(pref, val); e.commit(); } this method to get value from shared prefrences public static String getPref(Context c, String pref, String val) { return PreferenceManager.getDefaultSharedPreferences(c).getString(pref, val); }

Categories : Android

Multiple instances use a co-located caching but fail to access, good named caching implementation required
First I'd move your cache and cacheFactory instantiation out of your getPrices method. Also, evaluate your need for the lock - this may be causing timeouts. Another VERY important observation - you are using a constant cache key and saving/retrieving data for every productId with the same cache key. You should be using a cache key like: var cacheKey = string.format("priceDatabyProductId-{0}", productId);. You need to set some breakpoints and examine exactly what you are caching and retrieving from the cache. The code as written will save the first productId to the cache and then keep returning that data regardless of the productId. Here is a full working example we use in production using the "default" named cache in dedicated cache roles: public static class MyCache { private

Categories : Asp Net

Is querying a MySQL database dozens of times in order to allow effective caching better than a few large queries with less caching?
The correct answer is: It depends. Caching is a way of optimizing a recognized use pattern by shortcutting producing repeatedly expensive data with re-using the data from a previous run. So the first question you should answer is: It there an observed repeated use pattern that has a noticable "expensive" step of producing data? If not: Don't use caching that you still do not need, wait until you can observe something. The second question you should be able to answer is: Can you measure how long it takes with and without cache, and is the difference noticable? And the third important question to answer is: How can you clean the cache from outdated information if the original data gets changed, and you want that new data to be displayed instantly? So in your case you are asking if using

Categories : PHP

Caching dynamic pages / excluding parts from caching
Ok, the solution was fragment caching. First you have to set your secret phrase by setting define('W3TC_DYNAMIC_SECURITY', 'my_string'); in wp-config.php and then you can use PHP code like this <!-- mfunc echo "Hello World<br/>"; --><!-- /mfunc --> which outputs this dynamic code <?php echo "Hello World<br/>"; ?>

Categories : PHP

Azure Caching - Failure after upgrading to SDK 2.1 and caching 2.1
Not really an answer but some comments which might help you diagnose the problem: Visual Studio 2012/Update 3 - Please ensure that you have latest updates applied to VS. We had gone through similar problems and this was one of the things that helped us. Collect lots of cache diagnostics data - In your cache configuration section, change the Microsoft.WindowsAzure.Plugins.Caching.DiagnosticLevel value to 4 in your cache worker role's configuration section. After you do that, add the following lines of code in your cache worker role's OnStart() method: DiagnosticMonitorConfiguration dmConfig = DiagnosticMonitor.GetDefaultInitialConfiguration(); // Configure the collection of cache diagnostic data. CacheDiagnostics.ConfigureDiagnostics(dmConfig); DiagnosticMonitor.Start("Microsoft.Window

Categories : Caching

Python User-Defined Global Variables Across Modules: Issues calling them when other modules are run
Running a module as a script does not count as importing it as a module. When the Functions_Practice_Main.py script imports Functions_Practice, and Functions_Practice imports Functions_Practice_Main, Python doesn't care that the code in Functions_Practice_Main.py is already running as the main script. Python will run it again to produce the module. How do you fix this? Well, there are several things you should do. First, avoid circular imports if at all possible. Instead of having Functions_Practice import Functions_Practice_Main, pass any data Functions_Practice needs from Functions_Practice_Main as function arguments. In Functions_Practice_Main: Functions_Practice.interactive_remainder_test(name) In Functions_Practice: def interactive_remainder_test(name): number = inputData(na

Categories : Python

Including admin parts in modules(bundles) in symfony2 ansd calling them from other modules and templates
I think you misunderstood what Symfony2 offers you. I'll try to explain some of them for your use case. What I understood You want to create an admin panel on your website. It's a common case. What to do You should create a bundle for this whole content. Like AdminBundle Step by step Let's look at a Symfony2 directory structure. Here's an excerpt. project/ app/ config/ config.yml parameters.yml cache/ AppKernel.php src/ Acme/ DemoBundle/ Controller/ Resources/ config/ public/ views/ AcmeDemoBundle.php vendor/ symfony/ autoload.php web/ .htaccess app.php a

Categories : Symfony2

Ambient declations for javascript modules that add fields to interfaces in other modules
If the item you are extending is an interface, they are open in TypeScript, so you can just add the extras like so: interface ExpressServerRequest { myAdditionalThing(): void; } There are ways of declaring pretty much anything, so if this isn't the trick for your case just post the exiting ExpressServerRequest and I'll update the example. The version of express.d.ts I checked on Definitely Typed has ExpressServerRequest as an interface.

Categories : Node Js

Multi Client Server, Multi interface, Multi IP version Socket
You're not missing anything. It is accepting connections to ::1 you said? Then it will accept ipv6 connections. And since IPv6 is backwards compatible, if you've created the correct ipv6 socket, it should be able to send and receive ipv4 packets as well.

Categories : C

Configuring AngularJS modules - how does it affect the other modules in the app?
Here is what i think. Like any other angular $httpProvider is also singleton in nature which very well means any changes to it from any where including any module would affect other, or in other words changes are global.

Categories : Angularjs

What is distributed caching in terms of caching persistent data for multiple applications/ multiple instances of an application
My best attempt for answers: I would say both. A distributed cache means that the logical idea of a cache is spread across multiple distinct machines. For example, you might have 5 nodes in your cache, and each node is on it's on machine/VM. Usually once you need a distributed cache, your application is also distributed. Small website = one server, maybe one cache node. Big website = many web servers, distributed cache. Most distributed caches distribute the cache entries evenly amongst nodes. If you write an entry to one node, it will get replicated to all other nodes. The idea is that each cache node can be taken out of the "cluster" and you don't lose any data. The idea of having one cache entry on one machine is called sharding. It means you look at the cache key and then decide w

Categories : Caching

Django per-view caching not caching
I think there are some mistakes in your code :) UpdateCacheMiddleware must be the first middleware and FetchFromCacheMiddleware must be the last (https://docs.djangoproject.com/en/dev/topics/cache/#the-per-site-cache) Dont know if 'django_pylibmc' is a shortcut in your cachebackend but in my settings it is "django.core.cache.backends.memcached.PyLibMCCache" Maybe that helps.

Categories : Django

What does it mean to have modules inside other modules in Ruby?
It is essentially namespacing. You could do the same thing with just module Fabrication::Syntax::Make. For whatever reason, nesting them is what most well-known gems/projects do, and for that unknown reason I do too. I would love to get some insight as to why people generally prefer nesting over the more direct method.

Categories : Ruby

What's a popular programming technique to handle a failure in a Multi-Step, Multi-Tier process?
i would suggest that the database information is atomically correct at the time of insert. this goes pretty directly with proper normalization. so for example, if the customer enters his address, then that gets saved to the db - it is still valid even if the customer fails to make an order. similarly, if the customer places an order - that is valid, even if the credit card transaction fails - which would be a separate fact somewhere else. (this fact would be checked before say the shipping step was allowed) the email step would maybe change its message depending on the facts available, but you would not want to roll back a purchase if the email server was down for instance. so my suggestion: normalize well, and keep all info as it occurs, then check appropriately during key steps in t

Categories : Javascript

how to read files in multi process, multi threaded environment
If you want to create exclusive access to a file, you cannot use file locking, as on most OSes file locking is advisory, not mandatory. I'd suggest creating a common lock directory for all your processes; in this lock directory, you would create a directory per file you want to lock, right before you open a file. The big advantage is that directory creation, unlike file creation, is atomic; as such, you can use Files.createDirectory() (or File's .mkdir() if you still use Java6 but then don't forget to check the return code) to grab a lock on the files you read. If this fails, you know someone else is using the file. Of course, when you're done with a file, don't forget to remove the lock directory matching this file... (in a finally block) (note: with Java 7 you can use Files.newBuffer

Categories : Java

What are some ways to do multi-core programming on Android, not just multi-thread?
Use multithreading to use multi cores because the android operating system and Dalvik vertual machine (DVM) manage multitasking and use multicores when in need so you do not have to use any Api . To know more about them download this pdf.

Categories : Java

nodejs&couchbase work with multi-core cpu and multi-server
The creation of multiserver couchbase cluster is easy as a pie - just install couchbase on new server and add it to cluster with one button. Nodejs scaling is more difficult. If you have realtime game (i.e. you use websockets to handle players communication) you should look to nosql databases that have "pub-sub" out of the box (i.e. redis). There are some utils that implement "pub-sub" for memcached, but they are very ugly and their performance isn't good. But if your game isn't realtime (i.e. your game is like FarmVille) you can use couchbase as a "shared" layer between nodejs threads and servers.

Categories : Node Js

Multi-input, multi-output compilers with Shake
Writing rules which produce multiple outputs whose names cannot be statically determined can be a bit tricky. The usual approach is to find an output whose name is statically known and always need that, or if none exists, create a fake file to use as the static output (as per ghc-make, the .result file). In your case you have module.jar as the ultimate output, so I would write: "module.jar" *> out -> do javas <- getDirectoryFiles "" ["src//*.java"] need javas liftIO $ removeFiles "" ["bin//*"] liftIO $ createDirectory "bin" () <- cmd "javac -d bin" javas classes <- getDirectoryFiles "" ["bin//*.class"] need classes cmd "jar cf" [out] "-C bin ." There is no advantage to splitting it up into two rules, since you never depend on the .class fil

Categories : Haskell

Multi-user,Multi-Touch and simultaneous input
To my knowledge this is not currently possible on the Windows operating systems. I haven't heard of it being done in Windows but perhaps you could try to capture touch events and have another process emulate them into each window you want. I don't know if this sort of hacking is possible in Windows but i've seen it done in Linux systems.

Categories : C#

What do multi-processes VS multi-threaded servers most benefit from?
Unicorn is process based, which means that each instance of ruby will have to exist in its own process. That can be in the area of 500mb's for each process, which will quickly drain system resources. Puma, being thread based, won't use the same amount of memory to THEORETICALLY attain the same amount of concurrency. Unicorn, being that multiple processes are run, will have parallelism between the different processes. This is limited by your CPU cores (more cores can run more processes at the same time), but the kernel will switch between active processes so more than 4 or 8 processes (however many cores you have) can be run. You will be limited by your machine's memory. Until recently, ruby was not copy-on-write friendly, which meant that EVERY process had its own inherited memory (unicor

Categories : Ruby On Rails

using multi-markers with multi info-windows
Here's a compromise approach with one infoWindow per maker but the infowindows are not created in advance. Instead, they are created on-demand, as each marker is clicked. This way, infoWindows that will never be seen are not created. And once created, each infoWindow will be reused if the user revisits its marker. Outside the nested i/j loops : var AllMarkers = [];//Not necessary unless used elsewhere function clickMarker_closure(arr) { return function() { if(!this.infoWin) { this.infoWin = new google.maps.InfoWindow({ content: [ "Lat: " + this.position.lat(), "Lng: " + this.position.lng(), "Number of encounters: " + arr[2] ].join(" ") }); } t

Categories : Google Maps

When to put locks for multi-threading and multi-processing?
you can simplify to with lock: print(something) But yes, you need to avoid prints to be mixed by various threads. When using readonly variables, you do not need a lock. When reading files (because you're changing state), you do need.

Categories : Python

Multi-Domain, Multi-Client reCAPTCHA use
Before July 2014 (or so), it was possible to create a global key for reCAPTCHA through the reCaptcha admin page, as seen in the screenshot below. Unfortunately, this option is no longer available. Existing global keys still work, but it's no longer possible to create new global keys. Sorry. :(

Categories : PHP

PHP How can i copy multi files to multi folders
Of course not. Your nested loop is copying the files in such a way that they're bound to overwrite previous file copies. I think you need to use a simpler solution. Copying in a nested loop doesn't make any sense. If you have the source and destination files, then I suggest a single loop: $copyArray = array( array('source' => './folder1/test.txt', 'destination' => './folder2/test.txt'), array('source' => './folder1/test.txt', 'destination' => './folder2/test.txt')); foreach ($copyArray as $copyInstructions) { copy($copyInstructions['source'], $copyInstructions['destination']); } But make sure your destination file-names are different!

Categories : PHP

Persistence of a QMultihash
There is no standard way to do it, especially for arbitrary key and value types. Here is an example of how you can convert QMultiHash<int, double> to QVariant and back: QVariant convert(QMultiHash<int, double> hash) { QVariantList variant_hash; for(QMultiHash<int, double>::Iterator it = hash.begin(); it != hash.end(); ++it) { QVariantList list; list << it.key(); list << it.value(); variant_hash << QVariant(list); } return variant_hash; } QMultiHash<int, double> convert_back(QVariant variant_hash) { QMultiHash<int, double> new_hash; foreach(QVariant item, variant_hash.toList()) { new_hash.insertMulti(item.toList()[0].toInt(), item.toList()[1].toDouble()); } return new_hash; } It stores each item of the

Categories : C++

Persistence c#, Between two runs
You could save it in the configuration file, or you could save it in the registry. You can do both... You only have to choose. I don't like very much the registry, so I normally use the configuration file. Here there is the MSDN page that explain how to use Settings in C#.

Categories : C#

db.properties vs persistence.xml which one is better?
I assume, from the fact that you mention JSF, that you are building a web application for deployment to an application server. I also caveat this question in that I don't know about db.properties or where it comes from. When deploying to an application server, it is always best to configure your database connections in the container and expose them to the application via JNDI. This allows the container to manage connection pooling and credentials and keeps this information out of your WAR/EAR files. It also ensures that your WAR/EAR files are agnostic to the particular database instance, so can be deployed to a container in any environment without modification. Therefore, I recommend against configuring your datasource in persistence.xml. See also Difference between configuring data sou

Categories : Java

GAE and JPA persistence exception
The error message seems very clear The URL "file:/Applications/Eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.8.2/appengine-java-sdk-1.8.2/lib/opt/user/datanucleus/v2/datanucleus-api-jpa-3.1.3.jar" is already registered, and you are trying to register an identical plugin located at URL "file:/Users/Stefano/.m2/repository/org/datanucleus/datanucleus-api-jpa/3.1.3/datanucleus-api-jpa-3.1.3.jar." so suggest you put a single version of a jar in the CLASSPATH, otherwise you will get class loading problems.

Categories : Google App Engine

Spring and persistence.xml
Long story short, JPA's EntityManagerFactory will scan your classpath for classes decorated with @Entity annotation. JPQL queries will be translated into native SQL queries based on metadata (fields) of these classes.

Categories : Spring

OSGi and Persistence Units
You should be able to acquire the EntityManagerFactory as an OSGi service, you can (LDAP) filter the correct one using the service property osgi.unit.name as in: ServiceReference[] refs = null; String filter = "(osgi.unit.name=myPersistenceUnit)"; ServiceReference[] refs = ctx.getServiceReferences(EntityManagerFactory.class.getName(), filter); //Should only be one reference, check (throw exception etc) return (EntityManagerFactory)ctx.getService(refs[0]); You can check that all Persistence Units are present, by listing the EntityManagerFactory services (with properties) in your OSGi shell.

Categories : Java

HBase data persistence
"Before a KeyValue pair is written to a block, the order ..." Yes, new data could be treated as transaction, but they are of the same data format/structure as that after compaction. Which means, these "transaction" co-exists with old data and has no difference with the old data except the timestamp. When requests comes, hbase will look at both previous data and new data (the "transaction" you mentioned), but new data whose timestamp is newer will be returned. "Before a KeyValue pair is written to a block, the order of the key must be bigger than the previous one" I guess the point here is, before block is written to disk, keys are sorted in the memstore (a memory cache) to make sure "the order of the key must be bigger than the previous one".

Categories : Java

© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.