Source Code Cross Referenced for RMServant.java in  » ESB » celtix-1.0 » org » objectweb » celtix » bus » ws » rm » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ESB » celtix 1.0 » org.objectweb.celtix.bus.ws.rm 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.objectweb.celtix.bus.ws.rm;
002:
003:        import java.io.IOException;
004:        import java.util.logging.Level;
005:        import java.util.logging.Logger;
006:
007:        import javax.xml.datatype.Duration;
008:
009:        import org.objectweb.celtix.bus.configuration.wsrm.DestinationPolicyType;
010:        import org.objectweb.celtix.bus.ws.addressing.VersionTransformer;
011:        import org.objectweb.celtix.common.logging.LogUtils;
012:        import org.objectweb.celtix.ws.addressing.AddressingProperties;
013:        import org.objectweb.celtix.ws.addressing.v200408.AttributedURI;
014:        import org.objectweb.celtix.ws.rm.AcceptType;
015:        import org.objectweb.celtix.ws.rm.CreateSequenceResponseType;
016:        import org.objectweb.celtix.ws.rm.CreateSequenceType;
017:        import org.objectweb.celtix.ws.rm.Expires;
018:        import org.objectweb.celtix.ws.rm.Identifier;
019:        import org.objectweb.celtix.ws.rm.OfferType;
020:        import org.objectweb.celtix.ws.rm.wsdl.SequenceFault;
021:
022:        public class RMServant {
023:
024:            private static final Logger LOG = LogUtils
025:                    .getL7dLogger(RMServant.class);
026:
027:            // REVISIT assumption there is only a single outstanding unattached Identifier
028:            private Identifier unattachedIdentifier;
029:
030:            public RMServant() {
031:            }
032:
033:            /** 
034:             * Called on the RM handler upon inbound processing a CreateSequence request.
035:             * 
036:             * @param 
037:             * @return the CreateSequenceResponse.
038:             */
039:            public CreateSequenceResponseType createSequence(
040:                    RMDestination destination, CreateSequenceType cs,
041:                    AddressingProperties maps) throws SequenceFault {
042:
043:                CreateSequenceResponseType csr = RMUtils.getWSRMFactory()
044:                        .createCreateSequenceResponseType();
045:                csr.setIdentifier(destination.generateSequenceIdentifier());
046:
047:                DestinationPolicyType dp = destination.getDestinationPolicies();
048:                Duration supportedDuration = dp.getSequenceExpiration();
049:                if (null == supportedDuration) {
050:                    supportedDuration = SourceSequence.PT0S;
051:                }
052:                Expires ex = cs.getExpires();
053:                LOG.info("supported duration: " + supportedDuration);
054:
055:                if (null != ex
056:                        || supportedDuration.isShorterThan(SourceSequence.PT0S)) {
057:                    Duration effectiveDuration = supportedDuration;
058:                    if (null != ex
059:                            && supportedDuration.isLongerThan(ex.getValue())) {
060:                        effectiveDuration = supportedDuration;
061:                    }
062:                    ex = RMUtils.getWSRMFactory().createExpires();
063:                    ex.setValue(effectiveDuration);
064:                    csr.setExpires(ex);
065:                }
066:
067:                OfferType offer = cs.getOffer();
068:                if (null != offer) {
069:                    AcceptType accept = RMUtils.getWSRMFactory()
070:                            .createAcceptType();
071:                    if (dp.isAcceptOffers()) {
072:                        RMSource source = destination.getHandler().getSource();
073:                        LOG.fine("Accepting inbound sequence offer");
074:                        AttributedURI to = VersionTransformer.convert(maps
075:                                .getTo());
076:                        accept
077:                                .setAcksTo(RMUtils.createReference(to
078:                                        .getValue()));
079:                        SourceSequence seq = new SourceSequence(offer
080:                                .getIdentifier(), null, csr.getIdentifier());
081:                        seq.setExpires(offer.getExpires());
082:                        seq.setTarget(VersionTransformer
083:                                .convert(cs.getAcksTo()));
084:                        source.addSequence(seq);
085:                        source.setCurrent(csr.getIdentifier(), seq);
086:                        LOG
087:                                .fine("Making offered sequence the current sequence for responses to "
088:                                        + csr.getIdentifier().getValue());
089:                    } else {
090:                        LOG.fine("Refusing inbound sequence offer");
091:                        accept.setAcksTo(RMUtils
092:                                .createReference(Names.WSA_NONE_ADDRESS));
093:                    }
094:                    csr.setAccept(accept);
095:                }
096:
097:                DestinationSequence seq = new DestinationSequence(csr
098:                        .getIdentifier(), cs.getAcksTo(), destination);
099:                seq.setCorrelationID(maps.getMessageID().getValue());
100:                destination.addSequence(seq);
101:
102:                return csr;
103:            }
104:
105:            public void createSequenceResponse(RMSource source,
106:                    CreateSequenceResponseType csr, Identifier offeredId) {
107:                // moved from RMProxy.createSequence
108:                // csr.getIdentifier() is the Identifier for the newly created sequence
109:                SourceSequence seq = new SourceSequence(csr.getIdentifier());
110:                seq.setExpires(csr.getExpires());
111:                source.addSequence(seq);
112:
113:                // the incoming sequence ID is either used as the requestor sequence
114:                // (signalled by null) or associated with a corresponding sequence 
115:                // identifier
116:                source.setCurrent(clearUnattachedIdentifier(), seq);
117:
118:                // if a sequence was offered and accepted, then we can add this to
119:                // to the local destination sequence list, otherwise we have to wait for
120:                // and incoming CreateSequence request
121:                if (null != offeredId) {
122:                    assert null != csr.getAccept();
123:                    RMDestination dest = source.getHandler().getDestination();
124:                    String address = csr.getAccept().getAcksTo().getAddress()
125:                            .getValue();
126:                    if (!RMUtils.getAddressingConstants().getNoneURI().equals(
127:                            address)) {
128:                        DestinationSequence ds = new DestinationSequence(
129:                                offeredId, csr.getAccept().getAcksTo(), dest);
130:                        dest.addSequence(ds);
131:                    }
132:                }
133:            }
134:
135:            /**
136:             * Checks if the terminated sequence was created in response to a createSequence
137:             * request that included an offer for an inbound sequence which was accepted.
138:             * the offering identifier is equal to the identifier of the sequence now terminated,
139:             * and request termination of that sequence in turn.
140:             * 
141:             * @param destination
142:             * @param sid
143:             * @throws SequenceFault
144:             */
145:            public void terminateSequence(RMDestination destination,
146:                    Identifier sid) throws SequenceFault {
147:                // check if the terminated sequence was created in response to a a createSequence
148:                // request
149:
150:                DestinationSequence terminatedSeq = destination
151:                        .getSequence(sid);
152:                if (null == terminatedSeq) {
153:                    LOG.severe("No such sequence.");
154:                    return;
155:                }
156:
157:                destination.removeSequence(terminatedSeq);
158:
159:                // the following may be necessary if the last message for this sequence was a oneway
160:                // request and hence there was no response to which a last message could have been added
161:
162:                for (SourceSequence outboundSeq : destination.getHandler()
163:                        .getSource().getAllSequences()) {
164:                    if (outboundSeq.offeredBy(sid)
165:                            && !outboundSeq.isLastMessage()) {
166:
167:                        // send an out of band message with an empty body and a 
168:                        // sequence header containing a lastMessage element.
169:
170:                        RMProxy proxy = destination.getHandler().getProxy();
171:                        try {
172:                            proxy.lastMessage(outboundSeq);
173:                        } catch (IOException ex) {
174:                            LOG.log(Level.SEVERE,
175:                                    "Could not terminate correlated sequence.",
176:                                    ex);
177:                        }
178:
179:                        break;
180:                    }
181:                }
182:
183:            }
184:
185:            protected Identifier clearUnattachedIdentifier() {
186:                Identifier ret = unattachedIdentifier;
187:                unattachedIdentifier = null;
188:                return ret;
189:            }
190:
191:            protected void setUnattachedIdentifier(Identifier i) {
192:                unattachedIdentifier = i;
193:            }
194:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.