org.apache.felix.ipojo.annotations.Provides Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of org.apache.felix.ipojo.annotations Show documentation
Show all versions of org.apache.felix.ipojo.annotations Show documentation
iPOJO Annotation pack. contained annotations are used to define iPOJO component type.
The newest version!
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.felix.ipojo.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
/**
* This annotation declares that the component instances will provide a service.
*
*
* {@linkplain org.apache.felix.ipojo.annotations.Component @Component}
* {@code @Provides}
* public class MyComponent implements Service {
* // ...
* }
*
* @author Felix Project Team
*/
@Target({ElementType.TYPE, ElementType.ANNOTATION_TYPE})
public @interface Provides {
/**
* Set the provided specifications.
* It can be used to force the exposed service to use an implementation class
* (not an interface) as specification.
* Default : all implemented interfaces
*
*
* {@linkplain org.apache.felix.ipojo.annotations.Component @Component}
* {@code @Provides(specifications = AbsComponent.class)}
* public class MyComponent extends AbsComponent {
* // ...
* }
*
*/
Class[] specifications() default { };
/**
* Set the service object creation strategy.
* Multiple values are possible: {@literal SINGLETON}, {@literal SERVICE},
* {@literal METHOD}, {@literal INSTANCE} or the strategy fully qualified class name:
*
* - {@literal SINGLETON}: Default strategy
* - {@literal SERVICE}: OSGi Service Factory style, 1 POJO instance per consumer bundle
* - {@literal METHOD}: Delegates the creation to the factory-method of the component, method will be called every time the service reference is get.
* - {@literal INSTANCE}: Creates one service object per requiring instance
* - Any other value is interpreted as the qualified name of a {@code CreationStrategy} implementation
*
*/
String strategy() default "SINGLETON";
/**
* Allows adding static properties to the service.
* Nested properties are static service properties, so must contain the name,
* value and type as they are not attached to a field (cannot discover type through
* introspection).
* The array contains {@link StaticServiceProperty} elements.
* Default : No service properties
*
* {@linkplain org.apache.felix.ipojo.annotations.Component @Component}
* {@code @Provides}(
* properties = {
* {@code @StaticServiceProperty}(name = "size", type = "int", value = "5"),
* {@code @StaticServiceProperty}(name = "name", type = "java.lang.String", value = "OSGi")
* }
* )
* public class MyComponent implements Service {
* // ...
* }
*
*/
StaticServiceProperty[] properties() default {};
}