blob: b083dc53ef51aa89a63d19e5f9243c0c8baf816d [file] [log] [blame]
Carsten Ziegeler55c96d32012-06-13 12:03:35 +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.scrplugin.description;
20
Carsten Ziegeler9a496fe2012-06-27 06:20:28 +000021import java.util.LinkedHashSet;
Carsten Ziegeler55c96d32012-06-13 12:03:35 +000022import java.util.Set;
23
Carsten Ziegeler9452bb22012-06-13 13:08:05 +000024import org.apache.felix.scrplugin.annotations.ScannedAnnotation;
Carsten Ziegeler55c96d32012-06-13 12:03:35 +000025
26/**
27 * If a component is a service, the {@link ClassDescription} should
28 * contain a <code>ServiceDescription</code>.
29 *
30 * The service description defines whether this is a service factory
31 * and which interfaces this service implements.
32 */
33public class ServiceDescription extends AbstractDescription {
34
35 /** Flag for service factory. */
36 private boolean isServiceFactory = false;
37
38 /** The list of implemented interfaces. */
Carsten Ziegeler9a496fe2012-06-27 06:20:28 +000039 protected final Set<String> interfaces = new LinkedHashSet<String>();
Carsten Ziegeler55c96d32012-06-13 12:03:35 +000040
41 public ServiceDescription(final ScannedAnnotation annotation) {
42 super(annotation);
43 }
44
45 public boolean isServiceFactory() {
46 return this.isServiceFactory;
47 }
48
49 public void setServiceFactory(boolean flag) {
50 this.isServiceFactory = flag;
51 }
52
53 public Set<String> getInterfaces() {
54 return this.interfaces;
55 }
56
57 /**
58 * Add an interface to the list of interfaces.
59 * @param interf The interface.
60 */
61 public void addInterface(final String interf) {
62 this.interfaces.add(interf);
63 }
64
65 @Override
66 public String toString() {
67 return "ServiceDescription [isServiceFactory=" + isServiceFactory
68 + ", interfaces=" + interfaces + ", annotation=" + annotation
69 + "]";
70 }
Carsten Ziegeler547de0c2012-06-28 11:22:40 +000071
72 @Override
73 public AbstractDescription clone() {
74 final ServiceDescription cd = new ServiceDescription(this.annotation);
75 cd.setServiceFactory(this.isServiceFactory);
76 for(final String i : this.getInterfaces()) {
77 cd.addInterface(i);
78 }
79
80 return cd;
81 }
Carsten Ziegeler55c96d32012-06-13 12:03:35 +000082}