Change Spring configuraton on runtime - database

I need to use two different properties in Spring application-context.xml file depending on the database that is used in the application.
Are there any way to change a property in the Spring context depending on java.sql.DatabaseMetaData before the context is initialized?
Thank you very much!:)

It's possible to refresh your context once you load data and change the configuration regarding the values from database.
See http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/context/ConfigurableApplicationContext.html#refresh--

In that case it helped to inherit from Spring configuration class, and override methods in which I need to change a parameter. Thus, change in parameters occurs in runtime.
Refreshing context doesn't fit my needs as I need to load context in the correct way the first time.

Related

Using 2 views and sharing data in AngularJS

Im trying to share data between 2 views. I need to use the 2 views at the same time on two different machines. One is controlling the other(ex: a counter) 1st view has next(+1) and the other just displays the result. I want the data to synchronized/binded. I do not want to have to refresh the 2nd page or to have to pull data with a timer or otherwise.
My idea was to use ng-view and routeProvider, I know that when the view changes the scope is cleared so I tried to use a parent controller/scope, the data is shared but I have to refresh the page on my 2nd view. I tried a service, same thing. I tried to $watch the result of the service but on the second controller/view no event is picked up so the view doesn't update.
what is the way to go? I was thinking about broadcasting or emit a custom event and trying to catch it, will that work? Am I just not binding to the service correctly? Would ui-router work better? I feel there should be an easy way to do this.... Im not seeing it! Please help if you can.
One of the simplest (in my opinion) implementations of client-client communication is using WebSockets. While that does have compatibility limitations (some browsers), that can easily be overcome by using a library like socket.io. Also, it's easy to write an Angular wrapper/service over socket.io that can be shared across components of your app, or even different modules.
It's also pretty simple to write a Node backend with socket.io
This might be a good read.
I would suggest you to focus on pushing stream rather than sharing it. Some how you need to push stream to second view which is changes in first view.
You may want to check this
Is there some way to PUSH data from web server to browser?

Disable Dynamic Routing capability in Camel

With Camel, it is possible to add routes dynamically to the context. And it appears the context is always passed as part of the exchange.
Is there a way to prevent applications from adding routes at runtime? I looked at Shiro security but did not seem to find something along those lines.
the only thing I can think of is to wrap interactions with these applications using POJO Bean Binding which only passes the body of the Exhchange around and limits access to the Exchange directly...
see http://camel.apache.org/bean-binding.html
Maybe you can extend DefaultContext and add security rule in that.

Per installation configuration for SalesForce Application

I want my SalesForce Application to behave differently depending on a value that's set per environment. The value can be one of two values at present and will result in a different page being loaded and a different object instance being updated by the page.
Where would be the best place to store this? A single instance of a custom object? Or is there a dedicated store for this? Ideally the value could be updated using the Api so that a we can updated it without having to get clients to do it.
Sounds to me like you want to use a Custom Setting — these are similar to objects but setup exactly for this kind of thing, and they can even be done in a hierarchy such that different settings are used for different users.
Help for custom settings is here (must be logged in) and reference docs are here.

Data conflict resolution in Silverlight with WCF Service

When using Silverlight together with a WCF Services library how do you solve the age old possibility of two different users loading a record, making different changes to that record and then updating. In other words when updating how does the WCF service know that the data it retrieved is the same as the data it fetched before applying an update?
Do you need to check the original loaded values against the values in the database (i.e. recall the original query before updating)?
I was hoping that there would be a more out-of-the-box answer.
Do you mean using EntityFramework? If so, here is the strategy I used :
When retrieving data on the client side you see that the "RowState" property of the entity is gone. What I did is I added the property on the client side using the "partial class" feature. And I manage locally the value of that RowState value.
When the data goes back to the server for update only send what has been modified filtering by the "RowState" property.
On your Update method, call the ApplyCurrentValues() method of the object.
Maybe there is a better solution for that, but that's what I am using on my project; and it works well on my case :)
Good luck

How do I store some object globally?

I'm new to WPF and used to ASP.NET. I have a WPF app that will require a login screen. Throught the rest of the app I want to be able to access a "Session" object that will contain some credentials information. How do I store that so that any view in my app can access that object?
You can also use lightweight container to store objects globally in loosely coupled way and retrieve these object using Dependency Injection pattern.
One of implementations of lightweight container is Unity Application Block from Microsoft (http://www.codeplex.com/unity) so you can start there and read more here and here.
The Application object has a Properties property that allows you to store and retrieve application wide objects.
It is better explained here:
How to: Get and Set Application-Scope Properties
There are a few ways to do this.
You can create a static class, perhaps you might call it "Session" which holds the data that you are interested in. Session might have a Dictionary that contains the data that you are interested in.
You can hold the data in the main form, and have the main form pass a data container to each view.
There might be better ways to do this that are more compatible with your design goals if you can provide more details about the implementation and use cases.

Resources