Example usage for org.springframework.beans.factory BeanFactory getBean

List of usage examples for org.springframework.beans.factory BeanFactory getBean

Introduction

In this page you can find the example usage for org.springframework.beans.factory BeanFactory getBean.

Prototype

<T> T getBean(Class<T> requiredType) throws BeansException;

Source Link

Document

Return the bean instance that uniquely matches the given object type, if any.

Usage

From source file:es.urjc.mctwp.service.commands.adminCmds.RemoveTrialParticipation.java

public RemoveTrialParticipation(BeanFactory bf) {
    super(bf);/*  w w  w.  j  a v a  2s.com*/
    partDao = (ParticipationDAO) bf.getBean(BeanNames.PARTICIPATION_DAO);
    trialDao = (TrialDAO) bf.getBean(BeanNames.TRIAL_DAO);
    setActionName(ActionNames.REMOVE_TRIAL_PART);
    setReadOnly(false);
}

From source file:es.urjc.mctwp.service.commands.adminCmds.RemoveUserParticipation.java

public RemoveUserParticipation(BeanFactory bf) {
    super(bf);//from   w ww. j a  v  a2  s. c  o  m
    partDao = (ParticipationDAO) bf.getBean(BeanNames.PARTICIPATION_DAO);
    userDao = (UserDAO) bf.getBean(BeanNames.USER_DAO);
    setActionName(ActionNames.REMOVE_USER_PART);
    setReadOnly(false);
}

From source file:org.atmars.action.BaseAction.java

protected void InitAction() {
    webRootPath = ServletActionContext.getServletContext().getRealPath("/");
    String xmlPath = webRootPath + "WEB-INF\\applicationContext.xml";

    ApplicationContext appContext = new FileSystemXmlApplicationContext(xmlPath);
    //Resource res = new FileSystemResource(webRootPath
    //      + "WEB-INF\\applicationContext.xml");
    //XmlBeanFactory factory = new XmlBeanFactory(res);
    BeanFactory factory = appContext;
    mService = (MessageService) factory.getBean("messageService");
    uService = (UserService) factory.getBean("userService");
    jMail = (Jmail) factory.getBean("jmail");
    mailServiceMdp = (MailServiceMdp) factory.getBean("mailServiceMdp");
    factory.getBean("listnerContainer");
    ActionContext ctx = ActionContext.getContext();
    Map<String, Object> session = ctx.getSession();
    currentUserFromSession = (User) session.get("user");
}

From source file:es.urjc.mctwp.service.commands.imageCmds.LoadImage.java

public LoadImage(BeanFactory bf) {
    super(bf);
    imageManager = (ImageCollectionManager) bf.getBean(BeanNames.IMG_COL_MGR);
    setActionName(ActionNames.LOAD_IMAGE);
}

From source file:es.urjc.mctwp.service.commands.adminCmds.FindNotAssignedTrials.java

public FindNotAssignedTrials(BeanFactory bf) {
    super(bf);//from   w  ww .j  a  v a 2s.  co m
    trialDao = (TrialDAO) bf.getBean(BeanNames.TRIAL_DAO);
    userDao = (UserDAO) bf.getBean(BeanNames.USER_DAO);
    setActionName(ActionNames.FIND_NOT_ASGN_TRIALS);
}

From source file:es.urjc.mctwp.service.commands.adminCmds.FindNotAssignedUsers.java

public FindNotAssignedUsers(BeanFactory bf) {
    super(bf);/*from  w ww. j ava  2s . c  o  m*/
    trialDao = (TrialDAO) bf.getBean(BeanNames.TRIAL_DAO);
    userDao = (UserDAO) bf.getBean(BeanNames.USER_DAO);
    setActionName(ActionNames.FIND_NOT_ASGN_USERS);
}

From source file:es.urjc.mctwp.service.commands.imageCmds.DeleteTemporalImages.java

public DeleteTemporalImages(BeanFactory bf) {
    super(bf);//  ww  w.  j  a v a  2  s  .c  om
    imageManager = (ImageCollectionManager) bf.getBean(BeanNames.IMG_COL_MGR);
    setActionName(ActionNames.DELETE_TEMP_IMAGES);
}

From source file:es.urjc.mctwp.service.commands.researchCmds.FindNotAssignedModalities.java

public FindNotAssignedModalities(BeanFactory bf) {
    super(bf);//from   w w w  .ja v a  2  s. c  o  m
    modalityDao = (ModalityDAO) bf.getBean(BeanNames.MODALITY_DAO);
    userDao = (UserDAO) bf.getBean(BeanNames.USER_DAO);
    setActionName(ActionNames.FIND_NOT_ASGN_MODALS);
}

From source file:gaderian.test.utilities.TestSpringObjectProvider.java

public void testBasic() {
    Object bean = new Object();
    BeanFactory bf = createMock(BeanFactory.class);

    EasyMock.expect(bf.getBean("fred")).andReturn(bean);

    replayAllRegisteredMocks();/*from   w  w  w. ja  v a2  s  . c  om*/

    SpringObjectProvider p = new SpringObjectProvider();
    p.setBeanFactory(bf);

    Object result = p.provideObject(null, null, "fred", null);

    assertSame(bean, result);

    verifyAllRegisteredMocks();
}

From source file:de.tudarmstadt.lt.ltbot.writer.SentenceWriterTest.java

@Test
public void testbean() {
    Resource xmlResource = new FileSystemResource(
            "jobs/profile-ltbot-default-seedfile/profile-crawler-beans-ltbot.cxml");
    BeanFactory factory = new XmlBeanFactory(xmlResource);
    SentenceWriter w = (SentenceWriter) factory.getBean("sentenceWriterHtml");
    SentenceMaker m = (SentenceMaker) factory.getBean("sentenceMaker");

}