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.concurrent.atomic.AtomicReference;
025:
026: import org.netbeans.modules.bpel.model.api.BpelEntity;
027: import org.netbeans.modules.bpel.model.api.ExtendableActivity;
028: import org.netbeans.modules.bpel.model.api.OnMessage;
029: import org.netbeans.modules.bpel.model.api.VariableDeclaration;
030: import org.netbeans.modules.bpel.model.api.references.BpelReference;
031: import org.netbeans.modules.bpel.model.api.support.BpelModelVisitor;
032: import org.netbeans.modules.bpel.model.xam.AfterSources;
033: import org.netbeans.modules.bpel.model.xam.BpelAttributes;
034: import org.netbeans.modules.bpel.model.xam.BpelElements;
035: import org.netbeans.modules.xml.xam.Reference;
036: import org.netbeans.modules.xml.xam.dom.Attribute;
037: import org.w3c.dom.Element;
038:
039: /**
040: * @author ads
041: *
042: */
043: public class OnMessageImpl extends OnMessageCommonImpl implements
044: OnMessage, AfterSources {
045:
046: OnMessageImpl(BpelModelImpl model, Element e) {
047: super (model, e);
048: }
049:
050: OnMessageImpl(BpelBuilderImpl builder) {
051: super (builder, BpelElements.ON_MESSAGE.getName());
052: }
053:
054: /* (non-Javadoc)
055: * @see org.netbeans.modules.soa.model.bpel20.api.ActivityHolder#getActivity()
056: */
057: public ExtendableActivity getActivity() {
058: return getChild(ExtendableActivity.class);
059: }
060:
061: /* (non-Javadoc)
062: * @see org.netbeans.modules.soa.model.bpel20.api.ActivityHolder#setActivity(org.netbeans.modules.soa.model.bpel20.api.ExtendableActivity)
063: */
064: public void setActivity(ExtendableActivity activity) {
065: setChild(activity, ExtendableActivity.class);
066: }
067:
068: /*
069: * (non-Javadoc)
070: *
071: * @see org.netbeans.modules.soa.model.bpel20.api.ActivityHolder#removeActivity()
072: */
073: public void removeActivity() {
074: removeChild(ExtendableActivity.class);
075: }
076:
077: /* (non-Javadoc)
078: * @see org.netbeans.modules.soa.model.bpel20.api.BpelEntity#getElementType()
079: */
080: public Class<? extends BpelEntity> getElementType() {
081: return OnMessage.class;
082: }
083:
084: /* (non-Javadoc)
085: * @see org.netbeans.modules.soa.model.bpel20.api.VariableSpec#getVariable()
086: */
087: public BpelReference<VariableDeclaration> getVariable() {
088: return getBpelReference(BpelAttributes.VARIABLE_REF,
089: VariableDeclaration.class);
090: }
091:
092: /* (non-Javadoc)
093: * @see org.netbeans.modules.soa.model.bpel20.api.VariableSpec#removeVariable()
094: */
095: public void removeVariable() {
096: removeReference(BpelAttributes.VARIABLE_REF);
097: }
098:
099: /* (non-Javadoc)
100: * @see org.netbeans.modules.soa.model.bpel20.api.VariableSpec#setVariable(org.netbeans.modules.soa.model.bpel20.references.VariableReference)
101: */
102: public void setVariable(BpelReference<VariableDeclaration> value) {
103: setBpelReference(BpelAttributes.VARIABLE_REF, value);
104: }
105:
106: /* (non-Javadoc)
107: * @see org.netbeans.modules.soa.model.bpel20.api.references.ReferenceCollection#getReferences()
108: */
109: public Reference[] getReferences() {
110: Reference[] refs = super .getReferences();
111: Reference[] ret = new Reference[refs.length + 1];
112: System.arraycopy(refs, 0, ret, 1, refs.length);
113: ret[0] = getVariable();
114: return ret;
115: }
116:
117: /* (non-Javadoc)
118: * @see org.netbeans.modules.soa.model.bpel20.impl.BpelEntityImpl#acceptThis(org.netbeans.modules.soa.model.bpel20.api.support.BpelModelVisitor)
119: */
120: public void accept(BpelModelVisitor visitor) {
121: visitor.visit(this );
122: }
123:
124: /* (non-Javadoc)
125: * @see org.netbeans.modules.soa.model.bpel20.impl.ActivityImpl#create(org.w3c.dom.Element)
126: */
127: @Override
128: protected BpelEntity create(Element element) {
129: BpelEntity entity = Utils.createActivityGroup(getModel(),
130: element);
131: if (entity == null) {
132: return super .create(element);
133: }
134: return entity;
135: }
136:
137: /* (non-Javadoc)
138: * @see org.netbeans.modules.soa.model.bpel20.impl.BpelContainerImpl#getChildType(T)
139: */
140: @Override
141: protected <T extends BpelEntity> Class<? extends BpelEntity> getChildType(
142: T entity) {
143: if (entity instanceof ExtendableActivity) {
144: return ExtendableActivity.class;
145: }
146: return super .getChildType(entity);
147: }
148:
149: /* (non-Javadoc)
150: * @see org.netbeans.modules.bpel.model.impl.BpelContainerImpl#getMultiplicity(org.netbeans.modules.bpel.model.api.BpelEntity)
151: */
152: @Override
153: protected Multiplicity getMultiplicity(BpelEntity entity) {
154: if (getChildType(entity).equals(ExtendableActivity.class)) {
155: return Multiplicity.SINGLE;
156: }
157: return super .getMultiplicity(entity);
158: }
159:
160: /* (non-Javadoc)
161: * @see org.netbeans.modules.soa.model.bpel20.impl.BpelEntityImpl#getDomainAttributes()
162: */
163: protected Attribute[] getDomainAttributes() {
164: if (myAttributes.get() == null) {
165: Attribute[] attr = super .getDomainAttributes();
166: Attribute[] ret = new Attribute[attr.length + 1];
167: System.arraycopy(attr, 0, ret, 1, attr.length);
168: ret[0] = BpelAttributes.VARIABLE_REF;
169: myAttributes.compareAndSet(null, ret);
170: }
171: return myAttributes.get();
172: }
173:
174: private static AtomicReference<Attribute[]> myAttributes = new AtomicReference<Attribute[]>();
175:
176: }
|