001: /*
002: * The contents of this file are subject to the terms of the Common Development
003: * and Distribution License (the License). You may not use this file except in
004: * compliance with the License.
005: *
006: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007: * or http://www.netbeans.org/cddl.txt.
008: *
009: * When distributing Covered Code, include this CDDL Header Notice in each file
010: * and include the License file at http://www.netbeans.org/cddl.txt.
011: * If applicable, add the following below the CDDL Header, with the fields
012: * enclosed by brackets [] replaced by your own identifying information:
013: * "Portions Copyrighted [year] [name of copyright owner]"
014: *
015: * The Original Software is NetBeans. The Initial Developer of the Original
016: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017: * Microsystems, Inc. All Rights Reserved.
018: */
019:
020: /**
021: *
022: */package org.netbeans.modules.bpel.model.impl;
023:
024: import java.util.List;
025: import java.util.concurrent.atomic.AtomicReference;
026:
027: import org.netbeans.modules.bpel.model.api.BpelEntity;
028: import org.netbeans.modules.bpel.model.api.CorrelationContainer;
029: import org.netbeans.modules.bpel.model.api.FromPart;
030: import org.netbeans.modules.bpel.model.api.FromPartContainer;
031: import org.netbeans.modules.bpel.model.api.MessageExchange;
032: import org.netbeans.modules.bpel.model.api.OnMessageCommon;
033: import org.netbeans.modules.bpel.model.api.PartnerLink;
034: import org.netbeans.modules.bpel.model.api.references.BpelReference;
035: import org.netbeans.modules.bpel.model.api.references.WSDLReference;
036: import org.netbeans.modules.bpel.model.xam.BpelAttributes;
037: import org.netbeans.modules.bpel.model.xam.BpelElements;
038: import org.netbeans.modules.bpel.model.xam.BpelTypesEnum;
039: import org.netbeans.modules.xml.wsdl.model.Operation;
040: import org.netbeans.modules.xml.wsdl.model.PortType;
041: import org.netbeans.modules.xml.xam.Reference;
042: import org.netbeans.modules.xml.xam.dom.Attribute;
043: import org.w3c.dom.Element;
044:
045: /**
046: * @author ads
047: *
048: */
049: public abstract class OnMessageCommonImpl extends
050: ExtensibleElementsImpl implements OnMessageCommon {
051:
052: OnMessageCommonImpl(BpelModelImpl model, Element e) {
053: super (model, e);
054: }
055:
056: OnMessageCommonImpl(BpelBuilderImpl builder, String tagName) {
057: super (builder, tagName);
058: }
059:
060: /* (non-Javadoc)
061: * @see org.netbeans.modules.soa.model.bpel20.api.PartnerLinkReference#getPartnerLink()
062: */
063: public BpelReference<PartnerLink> getPartnerLink() {
064: return getBpelReference(BpelAttributes.PARTNER_LINK,
065: PartnerLink.class);
066: }
067:
068: /* (non-Javadoc)
069: * @see org.netbeans.modules.soa.model.bpel20.api.PartnerLinkReference#setPartnerLink(org.netbeans.modules.soa.model.bpel20.references.BpelReference)
070: */
071: public void setPartnerLink(BpelReference<PartnerLink> value) {
072: setBpelReference(BpelAttributes.PARTNER_LINK, value);
073: }
074:
075: /* (non-Javadoc)
076: * @see org.netbeans.modules.soa.model.bpel20.api.PortTypeReference#getPortType()
077: */
078: public WSDLReference<PortType> getPortType() {
079: return getWSDLReference(BpelAttributes.PORT_TYPE,
080: PortType.class);
081: }
082:
083: /* (non-Javadoc)
084: * @see org.netbeans.modules.soa.model.bpel20.api.PortTypeReference#setPortType(org.netbeans.modules.soa.model.bpel20.references.WSDLReference)
085: */
086: public void setPortType(WSDLReference<PortType> value) {
087: setWSDLReference(BpelAttributes.PORT_TYPE, value);
088: }
089:
090: /* (non-Javadoc)
091: * @see org.netbeans.modules.soa.model.bpel20.api.PortTypeReference#removePortType()
092: */
093: public void removePortType() {
094: removeReference(BpelAttributes.PORT_TYPE);
095: }
096:
097: /* (non-Javadoc)
098: * @see org.netbeans.modules.soa.model.bpel20.api.OperationReference#getOperation()
099: */
100: public WSDLReference<Operation> getOperation() {
101: return getWSDLReference(BpelAttributes.OPERATION,
102: Operation.class);
103: }
104:
105: /* (non-Javadoc)
106: * @see org.netbeans.modules.soa.model.bpel20.api.OperationReference#setOperation(org.netbeans.modules.soa.model.bpel20.api.support.WSDLReference)
107: */
108: public void setOperation(WSDLReference<Operation> value) {
109: setWSDLReference(BpelAttributes.OPERATION, value);
110: }
111:
112: /* (non-Javadoc)
113: * @see org.netbeans.modules.soa.model.bpel20.api.MessageExchangeSpec#getMessageExchange()
114: */
115: public BpelReference<MessageExchange> getMessageExchange() {
116: return getBpelReference(BpelAttributes.MESSAGE_EXCHANGE,
117: MessageExchange.class);
118: }
119:
120: /* (non-Javadoc)
121: * @see org.netbeans.modules.soa.model.bpel20.api.MessageExchangeSpec#setMessageExchange(java.lang.String)
122: */
123: public void setMessageExchange(BpelReference<MessageExchange> ref) {
124: setBpelReference(BpelAttributes.MESSAGE_EXCHANGE, ref);
125: }
126:
127: /* (non-Javadoc)
128: * @see org.netbeans.modules.soa.model.bpel20.api.MessageExchangeSpec#removeMessageExchange()
129: */
130: public void removeMessageExchange() {
131: removeReference(BpelAttributes.MESSAGE_EXCHANGE);
132: }
133:
134: /* (non-Javadoc)
135: * @see org.netbeans.modules.soa.model.bpel20.api.FromPartContainer#getFromParts()
136: */
137: public FromPart[] getFromParts() {
138: readLock();
139: try {
140: List<FromPart> list = getChildren(FromPart.class);
141: return list.toArray(new FromPart[list.size()]);
142: } finally {
143: readUnlock();
144: }
145: }
146:
147: /* (non-Javadoc)
148: * @see org.netbeans.modules.soa.model.bpel20.api.FromPartContainer#getFromPart(int)
149: */
150: public FromPart getFromPart(int i) {
151: return getChild(FromPart.class, i);
152: }
153:
154: /* (non-Javadoc)
155: * @see org.netbeans.modules.soa.model.bpel20.api.FromPartContainer#setFromPart(org.netbeans.modules.soa.model.bpel20.api.FromPart, int)
156: */
157: public void setFromPart(FromPart part, int i) {
158: setChildAtIndex(part, FromPart.class, i);
159: }
160:
161: /* (non-Javadoc)
162: * @see org.netbeans.modules.soa.model.bpel20.api.FromPartContainer#insertFromPart(org.netbeans.modules.soa.model.bpel20.api.FromPart, int)
163: */
164: public void insertFromPart(FromPart part, int i) {
165: insertAtIndex(part, FromPart.class, i,
166: BpelTypesEnum.ACTIVITIES_GROUP);
167: }
168:
169: /* (non-Javadoc)
170: * @see org.netbeans.modules.soa.model.bpel20.api.FromPartContainer#addFromPart(org.netbeans.modules.soa.model.bpel20.api.FromPart)
171: */
172: public void addFromPart(FromPart part) {
173: addChildBefore(part, FromPart.class,
174: BpelTypesEnum.ACTIVITIES_GROUP);
175: }
176:
177: /* (non-Javadoc)
178: * @see org.netbeans.modules.soa.model.bpel20.api.FromPartContainer#setFromParts(org.netbeans.modules.soa.model.bpel20.api.FromPart[])
179: */
180: public void setFromParts(FromPart[] parts) {
181: setArrayBefore(parts, FromPart.class,
182: BpelTypesEnum.ACTIVITIES_GROUP);
183: }
184:
185: /* (non-Javadoc)
186: * @see org.netbeans.modules.soa.model.bpel20.api.FromPartContainer#sizeOfFromParts()
187: */
188: public int sizeOfFromParts() {
189: readLock();
190: try {
191: return getChildren(FromPart.class).size();
192: } finally {
193: readUnlock();
194: }
195: }
196:
197: /* (non-Javadoc)
198: * @see org.netbeans.modules.soa.model.bpel20.api.FromPartContainer#removeFromPart(int)
199: */
200: public void removeFromPart(int i) {
201: removeChild(FromPart.class);
202: }
203:
204: /* (non-Javadoc)
205: * @see org.netbeans.modules.soa.model.bpel20.api.CorrelationsHolder#getCorrelationContainer()
206: */
207: public CorrelationContainer getCorrelationContainer() {
208: return getChild(CorrelationContainer.class);
209: }
210:
211: /* (non-Javadoc)
212: * @see org.netbeans.modules.soa.model.bpel20.api.CorrelationsHolder#removeCorrelationContainer()
213: */
214: public void removeCorrelationContainer() {
215: removeChild(CorrelationContainer.class);
216: }
217:
218: /* (non-Javadoc)
219: * @see org.netbeans.modules.soa.model.bpel20.api.CorrelationsHolder#setCorrelationContainer(org.netbeans.modules.soa.model.bpel20.api.CorrelationContainer)
220: */
221: public void setCorrelationContainer(CorrelationContainer value) {
222: setChild(value, CorrelationContainer.class,
223: BpelTypesEnum.FROM_PARTS,
224: BpelTypesEnum.ACTIVITIES_GROUP);
225: }
226:
227: /* (non-Javadoc)
228: * @see org.netbeans.modules.bpel.model.api.FromPartsHolder#getFromPartContaner()
229: */
230: public FromPartContainer getFromPartContaner() {
231: return getChild(FromPartContainer.class);
232: }
233:
234: /* (non-Javadoc)
235: * @see org.netbeans.modules.bpel.model.api.FromPartsHolder#removeFromPartContainer()
236: */
237: public void removeFromPartContainer() {
238: removeChild(FromPartContainer.class);
239: }
240:
241: /* (non-Javadoc)
242: * @see org.netbeans.modules.bpel.model.api.FromPartsHolder#setFromPartContainer(org.netbeans.modules.bpel.model.api.FromPartContainer)
243: */
244: public void setFromPartContainer(FromPartContainer value) {
245: setChild(value, FromPartContainer.class,
246: BpelTypesEnum.ACTIVITIES_GROUP);
247: }
248:
249: /* (non-Javadoc)
250: * @see org.netbeans.modules.soa.model.bpel20.api.references.ReferenceCollection#getReferences()
251: */
252: public Reference[] getReferences() {
253: return new Reference[] { getPartnerLink(), getPortType(),
254: getOperation(), getMessageExchange() }; // Fix for #81457
255: }
256:
257: /* (non-Javadoc)
258: * @see org.netbeans.modules.soa.model.bpel20.impl.InvokeReceiveReplyCommonImpl#create(org.w3c.dom.Element)
259: */
260: @Override
261: protected BpelEntity create(Element element) {
262: if (BpelElements.FROM_PARTS.getName().equals(
263: element.getLocalName())) {
264: return new FromPartConainerImpl(getModel(), element);
265: } else if (BpelElements.CORRELATIONS.getName().equals(
266: element.getLocalName())) {
267: return new CorrelationContainerImpl(getModel(), element);
268: }
269: return super .create(element);
270: }
271:
272: /* (non-Javadoc)
273: * @see org.netbeans.modules.bpel.model.impl.BpelContainerImpl#getMultiplicity(org.netbeans.modules.bpel.model.api.BpelEntity)
274: */
275: @Override
276: protected Multiplicity getMultiplicity(BpelEntity entity) {
277: if (getChildType(entity).equals(CorrelationContainer.class)) {
278: return Multiplicity.SINGLE;
279: } else if (getChildType(entity).equals(FromPartContainer.class)) {
280: return Multiplicity.SINGLE;
281: }
282: return super .getMultiplicity(entity);
283: }
284:
285: /* (non-Javadoc)
286: * @see org.netbeans.modules.soa.model.bpel20.impl.BpelEntityImpl#getDomainAttributes()
287: */
288: protected Attribute[] getDomainAttributes() {
289: if (myAttributes.get() == null) {
290: Attribute[] attr = super .getDomainAttributes();
291: Attribute[] ret = new Attribute[attr.length + 4];
292: System.arraycopy(attr, 0, ret, 4, attr.length);
293: ret[0] = BpelAttributes.PARTNER_LINK;
294: ret[1] = BpelAttributes.PORT_TYPE;
295: ret[2] = BpelAttributes.OPERATION;
296: ret[3] = BpelAttributes.MESSAGE_EXCHANGE;
297: myAttributes.compareAndSet(null, ret);
298: }
299: return myAttributes.get();
300: }
301:
302: private static AtomicReference<Attribute[]> myAttributes = new AtomicReference<Attribute[]>();
303:
304: }
|