EMMA Coverage Report (generated Fri Aug 21 15:59:46 BST 2009)
[all classes][org.springframework.batch.core.configuration.support]

COVERAGE SUMMARY FOR SOURCE FILE [OsgiBundleXmlApplicationContextFactory.java]

nameclass, %method, %block, %line, %
OsgiBundleXmlApplicationContextFactory.java100% (1/1)67%  (4/6)26%  (15/58)44%  (7/16)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class OsgiBundleXmlApplicationContextFactory100% (1/1)67%  (4/6)26%  (15/58)44%  (7/16)
createApplicationContext (): ConfigurableApplicationContext 0%   (0/1)0%   (0/39)0%   (0/7)
setApplicationContext (ApplicationContext): void 0%   (0/1)0%   (0/4)0%   (0/2)
OsgiBundleXmlApplicationContextFactory (): void 100% (1/1)100% (3/3)100% (1/1)
setBundleContext (BundleContext): void 100% (1/1)100% (4/4)100% (2/2)
setDisplayName (String): void 100% (1/1)100% (4/4)100% (2/2)
setPath (String): void 100% (1/1)100% (4/4)100% (2/2)

1/*
2 * Copyright 2006-2007 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 
17package org.springframework.batch.core.configuration.support;
18 
19import org.osgi.framework.BundleContext;
20import org.springframework.beans.BeansException;
21import org.springframework.context.ApplicationContext;
22import org.springframework.context.ApplicationContextAware;
23import org.springframework.context.ConfigurableApplicationContext;
24import org.springframework.osgi.context.BundleContextAware;
25import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext;
26 
27public class OsgiBundleXmlApplicationContextFactory implements BundleContextAware,
28                ApplicationContextFactory, ApplicationContextAware {
29 
30        private BundleContext bundleContext;
31 
32        private ApplicationContext parent;
33 
34        private String path;
35 
36        private String displayName;
37 
38        /**
39         * @param path
40         *            the resource path to the xml to load for the child context.
41         */
42        public void setPath(String path) {
43                this.path = path;
44        }
45        
46        /**
47         * @param displayName the display name for the application context created.
48         */
49        public void setDisplayName(String displayName) {
50                this.displayName = displayName;
51        }
52 
53        /**
54         * Setter for the parent application context.
55         * 
56         * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
57         */
58        public void setApplicationContext(ApplicationContext applicationContext)
59                        throws BeansException {
60                parent = applicationContext;
61        }
62 
63        /**
64         * Stash the {@link BundleContext} for creating a job application context
65         * later.
66         * 
67         * @see org.springframework.osgi.context.BundleContextAware#setBundleContext(org.osgi.framework.BundleContext)
68         */
69        public void setBundleContext(BundleContext context) {
70                this.bundleContext = context;
71        }
72 
73        /**
74         * Create an application context from the provided path, using the current
75         * OSGi {@link BundleContext} and the enclosing Spring
76         * {@link ApplicationContext} as a parent context.
77         * 
78         * @see ApplicationContextFactory#createApplicationContext()
79         */
80        public ConfigurableApplicationContext createApplicationContext() {
81                OsgiBundleXmlApplicationContext context = new OsgiBundleXmlApplicationContext(
82                                new String[] { path }, parent);
83                String displayName = bundleContext.getBundle().getSymbolicName() + ":" + this.displayName;
84                context.setDisplayName(displayName);
85                context.setBundleContext(bundleContext);
86                context.refresh();
87                return context;
88        }
89 
90}

[all classes][org.springframework.batch.core.configuration.support]
EMMA 2.0.5312 (C) Vladimir Roubtsov