Created
May 30, 2020 18:03
-
-
Save prashant4224/335b4428c75ac6e05860219d572ccf65 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.beans.factory.annotation.Lookup; | |
import org.springframework.stereotype.Component; | |
@Component | |
public class RequestManager{ | |
private RequestHandler requestHandler; | |
public void handleRequest(){ | |
requestHandler = getRequestHandler(); | |
requestHandler.handleRequest(); | |
} | |
@Lookup | |
public RequestHandler getRequestHandler() { | |
return null; | |
} | |
} | |
@Component | |
@Scope("prototype") | |
public class RequestHandler { | |
RequestHandler(){ | |
System.out.println("In Request Handler Constructor"); | |
} | |
public void handleRequest(){ | |
System.out.println("Handling request"); | |
} | |
} | |
public class App { | |
public static void main( String[] args ){ | |
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext | |
("appcontext.xml"); | |
RequestManager bean = (RequestManager) context.getBean("requestManager"); | |
bean.handleRequest(); | |
bean.handleRequest(); | |
bean.handleRequest(); | |
context.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment