blob: eba4df2e4511dfba3660d5e8f16d127d6fb9f2bc [file] [log] [blame]
Pierre De Ropfaca2892016-01-31 23:27:05 +00001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19package org.apache.felix.dm.lambda.samples.compositefactory;
20
Pierre De Ropfaca2892016-01-31 23:27:05 +000021/**
22 * Pojo used to create all the objects composition used to implements the "Provider" Service.
23 * The manager is using a Configuration injected by Config Admin, in order to configure the
24 * various objects being part of the "Provider" service implementation.
25 *
26 * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
27 */
28public class ProviderFactory {
29 private ProviderComposite1 m_composite1;
30 private ProviderComposite2 m_composite2;
31 private ProviderImpl m_providerImpl;
32 @SuppressWarnings("unused")
Pierre De Rop11527502016-02-18 21:07:16 +000033 private MyConfig m_conf;
Pierre De Ropfaca2892016-01-31 23:27:05 +000034
Pierre De Rop11527502016-02-18 21:07:16 +000035 public void updated(MyConfig conf) {
36 m_conf = conf; // conf.getFoo() returns "bar"
Pierre De Ropfaca2892016-01-31 23:27:05 +000037 }
38
39 /**
40 * Builds the composition of objects used to implement the "Provider" service.
41 * The Configuration injected by Config Admin will be used to configure the components
42 * @return The "main" object providing the "Provider" service.
43 */
44 ProviderImpl create() {
45 // Here, we can instantiate our object composition and configure them using the injected Configuration ...
46 m_composite1 = new ProviderComposite1(); // possibly configure this object using our configuration
47 m_composite2 = new ProviderComposite2(); // possibly configure this object using our configuration
48 m_providerImpl = new ProviderImpl(m_composite1, m_composite2);
49 return m_providerImpl; // Main object implementing the Provider service
50 }
51
52 /**
53 * Returns the
54 * @return
55 */
56 Object[] getComposition() {
57 return new Object[] { m_providerImpl, m_composite1, m_composite2 };
58 }
59}