summaryrefslogtreecommitdiffstats
path: root/branches/pre-spec-changes/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AtomicComponent.java
blob: aa4c41889bb2402d4be44f573d3eaac5bbb5dd66 (plain)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
 * 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.tuscany.spi.component;

import java.util.List;

import org.apache.tuscany.spi.ObjectCreationException;
import org.apache.tuscany.spi.wire.InboundWire;
import org.apache.tuscany.spi.wire.OutboundWire;

/**
 * The runtime instantiation of an SCA atomic, or leaf-type, component
 *
 * @version $Rev$ $Date$
 */
public interface AtomicComponent extends Component {

    /**
     * Returns true if component instances should be eagerly initialized.
     *
     * @return true if component instances should be eagerly initialized
     */
    boolean isEagerInit();

    /**
     * Returns true if component instances receive destroy events.
     *
     * @return true if component instances receive destroy events
     */
    boolean isDestroyable();

    /**
     * Returns the initialization level for this component.
     *
     * @return the initialization level for this component
     */
    int getInitLevel();

    /**
     * Returns the idle time allowed between operations in milliseconds if the implementation is conversational.
     *
     * @return the idle time allowed between operations in milliseconds if the implementation is conversational
     */
    long getMaxIdleTime();

    /**
     * Returns the maximum age a conversation may remain active in milliseconds if the implementation is
     * conversational.
     *
     * @return the maximum age a conversation may remain active in milliseconds if the implementation is conversational
     */
    long getMaxAge();

    /**
     * Adds a target-side wire. Target-side wire factories contain the invocation chains associated with the destination
     * service of a wire
     */
    void addInboundWire(InboundWire wire);

    /**
     * Adds a source-side wire for the given reference. Source-side wires contain the invocation chains for a reference
     * in the implementation associated with the instance wrapper created by this configuration.
     */
    void addOutboundWire(OutboundWire wire);

    /**
     * Adds a set of source-side multiplicity wires for the given reference. Source-side wires contain the invocation
     * chains for a reference in the implementation associated with the instance wrapper created by this configuration.
     */
    void addOutboundWires(List<OutboundWire> wires);

    /**
     * Notifies the given instance of an initialization event.
     *
     * @throws TargetInitializationException
     */
    void init(Object instance) throws TargetInitializationException;

    /**
     * Notifies the given instance of a destroy event.
     *
     * @throws TargetDestructionException
     */
    void destroy(Object instance) throws TargetDestructionException;

    /**
     * Creates a new implementation instance, generally used as a callback by a {@link
     * org.apache.tuscany.spi.component.ScopeContainer}.
     *
     * @return the instance
     * @throws ObjectCreationException
     */
    Object createInstance() throws ObjectCreationException;

    /**
     * Removes an implementation instance associated with the current invocation context.
     *
     * @throws ComponentException
     */
    void removeInstance() throws ComponentException;

    /**
     * Returns the target instance associated with the component. A target instance is the actual object a request is
     * dispatched to sans wire chain.
     *
     * @throws TargetResolutionException
     */
    Object getTargetInstance() throws TargetResolutionException;

}