Click here to Skip to main content
15,889,096 members
Home / Discussions / Java
   

Java

 
GeneralRe: sir,i want create setup file which can run on client desktop and my database sql server on java netbeans Pin
Richard MacCutchan29-May-16 22:15
mveRichard MacCutchan29-May-16 22:15 
Questionoffline handwriting recognition using neural networks in java‏ Pin
Member 1254061927-May-16 4:45
Member 1254061927-May-16 4:45 
SuggestionRe: offline handwriting recognition using neural networks in java‏ Pin
Richard MacCutchan27-May-16 5:30
mveRichard MacCutchan27-May-16 5:30 
GeneralRe: offline handwriting recognition using neural networks in java‏ Pin
Member 1254061927-May-16 10:29
Member 1254061927-May-16 10:29 
GeneralRe: offline handwriting recognition using neural networks in java‏ Pin
Richard MacCutchan27-May-16 21:37
mveRichard MacCutchan27-May-16 21:37 
QuestionWhat is Spring like? Pin
Member 1206160025-May-16 1:36
Member 1206160025-May-16 1:36 
AnswerRe: What is Spring like? Pin
Richard MacCutchan25-May-16 5:57
mveRichard MacCutchan25-May-16 5:57 
AnswerRe: What is Spring like? Pin
Kimberly Weldon5-Jul-16 23:13
Kimberly Weldon5-Jul-16 23:13 
Basically Spring is a framework for dependency-injection which is a pattern that allows to build very decoupled systems.

For example, suppose you need to list the users of the system and thus declare an interface called UserLister:

JavaScript
public interface UserLister {
    List<User> getUsers();
}


And maybe an implementation accessing a database to get all the users:

C#
public class UserListerDB implements UserLister {
    public List<User> getUsers() {
        // DB access code here
    }
}


In your view you'll need to access an instance (just an example, remember):

C#
public class SomeView {
    private UserLister userLister;

    public void render() {
        List<User> users = userLister.getUsers();
        view.render(users);
    }
}



Spring (Dependency Injection) approach

What Spring does is to wire the classes up by using a XML file, this way all the objects are instantiated and initialized by Spring and injected in the right places (Servlets, Web Frameworks, Business classes, DAOs, etc, etc, etc...).

Going back to the example in Spring we just need to have a setter for the userLister field and have an XML like this:

<bean id="userLister" class="UserListerDB" />

<bean class="SomeView">
    <property name="userLister" ref="userLister" />
</bean>



It is great, isn't it? Cool | :cool:
QuestionWhat is the good use-case example for Java generics besides collection framework? Pin
ygnusin23-May-16 2:59
ygnusin23-May-16 2:59 
AnswerRe: What is the good use-case example for Java generics besides collection framework? Pin
Richard MacCutchan23-May-16 3:35
mveRichard MacCutchan23-May-16 3:35 
QuestionMapped drives not included in File.listRoots() Pin
hansoctantan18-May-16 23:41
professionalhansoctantan18-May-16 23:41 
Questionproject request Pin
Salma Yossef18-May-16 11:39
Salma Yossef18-May-16 11:39 
AnswerRe: project request Pin
Richard MacCutchan18-May-16 21:07
mveRichard MacCutchan18-May-16 21:07 
Questionintegrated a bootstrap with spring mvc3 Pin
Member 1253127718-May-16 7:46
Member 1253127718-May-16 7:46 
AnswerRe: integrated a bootstrap with spring mvc3 Pin
Richard MacCutchan18-May-16 21:07
mveRichard MacCutchan18-May-16 21:07 
QuestionProduce repmat() method using java Pin
Member 1207967715-May-16 8:42
Member 1207967715-May-16 8:42 
AnswerRe: Produce repmat() method using java Pin
Richard MacCutchan15-May-16 20:56
mveRichard MacCutchan15-May-16 20:56 
QuestionSend Mail From Lotus Notes 9 Pin
Member 1252399114-May-16 17:19
Member 1252399114-May-16 17:19 
Questionglassfish alternatedocroot [moved to web development] Pin
V.12-May-16 22:02
professionalV.12-May-16 22:02 
GeneralRe: glassfish alternatedocroot Pin
Richard MacCutchan12-May-16 23:17
mveRichard MacCutchan12-May-16 23:17 
GeneralRe: glassfish alternatedocroot Pin
V.12-May-16 23:21
professionalV.12-May-16 23:21 
GeneralRe: glassfish alternatedocroot Pin
Richard MacCutchan12-May-16 23:24
mveRichard MacCutchan12-May-16 23:24 
QuestionThe problem about java multiple inheritance Pin
tzungshian6-May-16 20:20
tzungshian6-May-16 20:20 
AnswerRe: The problem about java multiple inheritance Pin
Richard MacCutchan6-May-16 22:47
mveRichard MacCutchan6-May-16 22:47 
GeneralRe: The problem about java multiple inheritance Pin
tzungshian7-May-16 0:34
tzungshian7-May-16 0:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.