I have got my properties defined using JNDI Entries on the server rather than an application properties file. This caused issues with my JUnits as they don't access the server. In my JUnit I used the method useOverridePropertiesWithPropertiesComponent to add a list of properties which has resolved my issue. I'd rather add a file test.properties and list my properties in here instead. Can this be done using this or a similar method?
Related
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.
I'm using a properties file in project. I want to read the properties file both java and angularjs. suggest me a best location to place the properties file which can accessible by java and also by angularjs.
By design it should be src/resources folder.
Well by opportunity, it can be placed in webapp too.
From what I know angularjs is meant to execute on browser. I do not recommend downloading properties into browser as web assets similar to css/js. So I would recommend keeping properties in src/main/resources/. If you need, host a small rest end point giving these properties as a json map in response. This can be used by angularjs on client side(browser)
Ideally properties which have confidential information shoild never be sent to browser.
Any one can get access to those information by debugging in tools like chrome,etc.
Sending such information should not create problems for your system. In those cases you shld hv 2 properties in src/ resources folder. One contains db passwords etc. Other with open information.
I have a Silverlight web project where I apply the MVVM pattern. In my entire solution I have 4 projects.
Project "A3", which contains all of my Views and ViewModels.
Project "A3.Web", which contains my main html files, images, sound files, etc.
Project "A3Lib", which contains my XAML binding converters and other helpful classes that I created.
Project "A3Lib.Web", which contains the Data Models and Domain Logic.
All of my entity models are inside my DataModels folder and all of my Domain Service server side code is inside the DomainLogic folder. I created a new folder inside the DataModels folder named "Common".
So when I want to add the data model to my VM, I tried "using A3Lib.Web.DataModels.Common;" and that did not find the namespace.
Issue: when I add a new folder and a new entity model to the DataModels folder, I do not see the namespace in my View or ViewModel in the "A3" project.
However, I already have existing code there (was added by someone else) and the models he added show perfectly fine (when doing using ...... in the View or VM).
I checked web.config to make sure the connection string is there and it's correct. I also tried to add a brand new context to the base class of the project (where other contexts are) and that did not help. My project simply cannot resolve or see the data model namespace that I create.
Thanks
Yura
The Silverlight app sees the models and namespaces from the server-side project through the generated code - you should see it in the Generated_Code folder of your A3Lib project. If it is not there, then the proxy classes are not being generated on build. A couple things to check:
class is not private (hey - sometimes it's the simple things)
if using Domain Services, the service needs to have at least 1 method that returns an IQueryable or IEnumerable (even if method returns null) in order to see the class in the Silverlight-side domaincontext
if the class is just a utility class that you want to share with the client, save the file as classname.shared.cs, and the proxy will pick it up.
make sure the project references are to the projects and not (possibly older) .dlls in another location.
That's all I've got based on the info provided.
I have the following Ria Service define:
namespace SilverlightTest.Web
{
[EnableClientAccess()]
public class ContactService : LinqToEntitiesDomainService<AdventureWorksEntities>
{
public IQueryable<Contact> GetContactSearch(string lastName)
{
ContactRepository rep = new ContactRepository();
return rep.SearchByLastName(lastName);
}
}
}
When I compile the solution, my SilverlightTest project does create the SilverlightTest.Web.g.cs file and the appropriate Context objects are created when I look at it. However, when I attempt to import the SilverlightTest.Web namespace to access the Data Context class for the above service, it says it cannot find the Web namespace.
The only difference I can see between what I'm doing and many examples that are out there on the web is that my AdventureWorksEntities data context is located in a separate business object dll. I tried to query the context directly instead of using the Repository Pattern I'm attempting to do and it also isn't work working.
Any ideas? Is it possible to have Ria Services access a separate DLL handling data access or does it HAVE to be in the same project?
I've been able to put the Ria service in a separate project before, although I do remember having issues. Not sure exactly what it was, but I would check two things: your references and your web.config (in the hosting website). When you add a ria service to a web project it does some things behind the scenes that wire everything up correctly.
Could try adding a service to your web project temporarily and see what it adds.
It seems that Resharper does not recognize the .gs files and their name spaces. If you disable R# or just code without intelisense it works.
I've been developing an AppEngine site which uses the Expando class to store info. I can successfully store a property in the development server. I verify the info is there with the developer (web) console, but when I run code I have the following problems:
- the hasattr(myobj, attr_name) function returns false
- the getattr(myobj, attr_name) function throws an exception
- myobj.attr_name throws an exception
- myobj.dynamic_properties() returns an empty list
All of these happen while the development (web) console reports the property is still there.
Also, if I set a new property (and commit it to the datastore) the old property disappears. This class was recently changed from a db.Model subclass to an Expando subclass. More strangely, another Expando subclass properly reports its dynamic properties.
I've re-installed the dev server (GoogleAppEngineLauncher 1.1.9 on Mac OS X 10.5.6) and cleared the datastore with no luck. I'm kind of stuck.
I figured this out. Apparently I was using the superclass'
Model.get('key')
method, instead of
db.get('key')
Duh.