My favorites | Sign in
Project Home Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* @(#)StubItest.java 8 Apr 2009
*
* Copyright © 2009 Andrew Phillips.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.qrmedia.commons.multispi.example;

import static com.google.common.collect.Iterables.get;

import java.util.Set;

import org.junit.Test;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;

import com.qrmedia.commons.multispi.MultiSpi;

/**
* Using {@link MultiSpi} to create a Spring-wireable sets.
*
* @author anphilli
* @since 8 Apr 2009
*
*/
public class SpringAgentExample {

@Test
public void go() {
XmlBeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("agentContext.xml"));
Set<?> agentNames = (Set<?>) beanFactory.getBean("agentNames");
System.out.format("Agent names: %s (class of items in set: '%s')%n", agentNames,
get(agentNames, 0).getClass());

Set<?> agentClasses = (Set<?>) beanFactory.getBean("agentClasses");
System.out.format("Agent classes: %s (class of items in set: '%s')%n", agentClasses,
get(agentClasses, 0).getClass());

Set<?> agents = (Set<?>) beanFactory.getBean("agents");
System.out.format("Agents: %s%n", agents);
}
}

Change log

r1867 by sharedocs1 on Feb 12, 2011   Diff
Expanded the Spring example to add
demonstrations of other MultiSPI methods
Go to: 
Project members, sign in to write a code review

Older revisions

r1601 by sharedocs1 on Dec 5, 2010   Diff
Initial import.
All revisions of this file

File info

Size: 1959 bytes, 54 lines
Powered by Google Project Hosting