587
|
1 |
/*
|
|
2 |
* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
package com.nokia.helium.signal.ant.types;
|
|
20 |
|
|
21 |
|
|
22 |
import java.util.Vector;
|
|
23 |
|
628
|
24 |
import org.apache.log4j.Logger;
|
|
25 |
import org.apache.tools.ant.BuildException;
|
587
|
26 |
import org.apache.tools.ant.types.DataType;
|
|
27 |
|
628
|
28 |
import com.nokia.helium.core.ant.types.ReferenceType;
|
587
|
29 |
import com.nokia.helium.signal.Notifier;
|
|
30 |
|
|
31 |
/**
|
|
32 |
* SignalInput class which is a type to store input for signals
|
|
33 |
* Signals..
|
628
|
34 |
*
|
|
35 |
* <pre>
|
|
36 |
* <hlm:signalInput id="testDeferredSignalInput">
|
|
37 |
* </hlm:notifierList refid="defaultNotiferList" >
|
|
38 |
* </hlm:signalInput>
|
|
39 |
*
|
|
40 |
* <hlm:signal name="compileSignal" result="${result}">
|
|
41 |
* <-- Let's refer to some existing signal input configuration -->
|
|
42 |
* <hlm:signalInput refid="testDeferredSignalInput" />
|
|
43 |
* </hlm:signal>
|
|
44 |
* </pre>
|
587
|
45 |
*
|
628
|
46 |
* @ant.type name="signalInput" category="Signaling"
|
587
|
47 |
*/
|
|
48 |
public class SignalInput extends DataType
|
|
49 |
{
|
|
50 |
private Vector<ReferenceType> notifierListRef = new Vector<ReferenceType>();
|
|
51 |
|
|
52 |
private Vector<NotifierInput> notifierInputList = new Vector<NotifierInput>();
|
|
53 |
|
|
54 |
// By default it is configured to fail the build.
|
|
55 |
private String failBuild = "now";
|
|
56 |
|
|
57 |
private Logger log = Logger.getLogger(SignalInput.class);
|
|
58 |
|
|
59 |
|
|
60 |
/**
|
628
|
61 |
* Defines how the signal framework should handle the error, either
|
|
62 |
* fail "now", at the end of the build "defer", or ignore the failure
|
|
63 |
* with "never".
|
587
|
64 |
* @param failBuild type of failure for this input.
|
628
|
65 |
* @ant.not-required Default is now.
|
587
|
66 |
*/
|
|
67 |
public void setFailBuild(FailBuildEnum failInput) {
|
|
68 |
failBuild = failInput.getValue();
|
|
69 |
}
|
|
70 |
|
|
71 |
/**
|
|
72 |
* Helper function called by ant to set the failbuild type
|
|
73 |
* @param failBuild type of failure for this input.
|
|
74 |
*/
|
|
75 |
public String getFailBuild() {
|
|
76 |
return failBuild;
|
|
77 |
}
|
|
78 |
|
|
79 |
/**
|
|
80 |
* Helper function called by ant to create a new notifier for
|
|
81 |
* this input.
|
|
82 |
* @return ReferenceType created ReferenceType.
|
|
83 |
*/
|
|
84 |
public NotifierInput createNotifierInput() {
|
|
85 |
NotifierInput notifierInput = new NotifierInput();
|
|
86 |
add(notifierInput);
|
|
87 |
return notifierInput;
|
|
88 |
}
|
|
89 |
|
|
90 |
/**
|
|
91 |
* Adds the created notifier to the list
|
|
92 |
* @param ReferenceType notifier to be added to the list.
|
|
93 |
*/
|
|
94 |
public void add(NotifierInput notifierInput) {
|
|
95 |
if (notifierInput != null) {
|
|
96 |
notifierInputList.add(notifierInput);
|
|
97 |
}
|
|
98 |
}
|
|
99 |
|
|
100 |
/**
|
|
101 |
* Helper function called by ant to create a new notifier for
|
|
102 |
* this input.
|
|
103 |
* @return ReferenceType created ReferenceType.
|
|
104 |
*/
|
|
105 |
public ReferenceType createNotifierListRef() {
|
|
106 |
ReferenceType notifierRef = new ReferenceType();
|
|
107 |
add(notifierRef);
|
|
108 |
return notifierRef;
|
|
109 |
}
|
|
110 |
|
|
111 |
/**
|
|
112 |
* Adds the created notifier to the list
|
|
113 |
* @param ReferenceType notifier to be added to the list.
|
|
114 |
*/
|
|
115 |
public void add(ReferenceType notifier) {
|
|
116 |
if (notifier != null) {
|
|
117 |
notifierListRef.add(notifier);
|
|
118 |
}
|
|
119 |
}
|
|
120 |
|
|
121 |
public Vector<NotifierInput> getNotifierInput() {
|
|
122 |
return notifierInputList;
|
|
123 |
}
|
|
124 |
|
|
125 |
/**
|
|
126 |
* Gets the NotifierList associated with this input. If the
|
|
127 |
* notifier list reference is empty then it throws exception.
|
|
128 |
* @return List of notifier associated with this input.
|
|
129 |
*/
|
|
130 |
public Vector<Notifier> getSignalNotifierList() {
|
|
131 |
Vector<Notifier> notifierList = null;
|
|
132 |
if (notifierListRef != null) {
|
|
133 |
log.debug("getSignalNotifierList:list.size:" + notifierListRef.size());
|
|
134 |
for (ReferenceType notifierRef : notifierListRef) {
|
|
135 |
Object obj = notifierRef.getReferencedObject();
|
|
136 |
if (obj instanceof SignalNotifierList) {
|
|
137 |
notifierList = ((SignalNotifierList)obj).getNotifierList();
|
|
138 |
break;
|
|
139 |
}
|
|
140 |
}
|
|
141 |
return notifierList;
|
|
142 |
}
|
|
143 |
throw new BuildException("No signal notifierlist reference defined.");
|
|
144 |
}
|
|
145 |
} |