1 /* 2 * Copyright (c) 2007, Fraunhofer-Gesellschaft 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: 8 * 9 * (1) Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the disclaimer at the end. 11 * Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in 13 * the documentation and/or other materials provided with the 14 * distribution. 15 * 16 * (2) Neither the name of Fraunhofer nor the names of its 17 * contributors may be used to endorse or promote products derived 18 * from this software without specific prior written permission. 19 * 20 * DISCLAIMER 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 * 34 */ 35 package org.ogf.graap.wsag.wsrf.sg.impl; 36 37 import org.apache.muse.core.Resource; 38 import org.apache.muse.core.serializer.SerializerRegistry; 39 import org.apache.muse.ws.addressing.EndpointReference; 40 import org.apache.muse.ws.addressing.soap.SoapFault; 41 import org.apache.muse.ws.resource.sg.MembershipContentRule; 42 import org.ogf.graap.wsag.wsrf.XmlUtils; 43 import org.ogf.graap.wsag.wsrf.impl.AgreementWsResource; 44 import org.w3.x2005.x08.addressing.EndpointReferenceType; 45 46 /** 47 * AgreementFactoryContentRule 48 * 49 * @author Oliver Waeldrich 50 * 51 */ 52 public class AgreementServiceGroup extends ServiceGroup 53 { 54 55 /** 56 * Extends the basic functionality of a service group. For local resources we set the port type of the 57 * resource in the MembershipContentRuleContext. After invocation we remove it from the context. 58 * 59 * @param memberEPR 60 * the endpoint reference of the resource to add 61 * 62 * @param resource 63 * the resource to add 64 * 65 * @throws SoapFault 66 * the resource could not be added 67 * 68 * @see org.apache.muse.ws.resource.sg.impl.SimpleServiceGroup#resourceAdded(org.apache.muse.ws.addressing.EndpointReference 69 * , org.apache.muse.core.Resource) 70 */ 71 public void resourceAdded( EndpointReference memberEPR, Resource resource ) throws SoapFault 72 { 73 try 74 { 75 EndpointReference museRegistryEPR = getResource().getEndpointReference(); 76 EndpointReferenceType registryEPR = XmlUtils.convertMuseEPRToEndpoint( museRegistryEPR ); 77 78 MembershipContentRuleContext.setRegistryEPR( registryEPR ); 79 80 if ( resource instanceof AgreementWsResource ) 81 { 82 EndpointReferenceType factoryEPR = ( (AgreementWsResource) resource ).getFactoryEPR(); 83 MembershipContentRuleContext.setFactoryEPR( factoryEPR ); 84 } 85 86 super.resourceAdded( memberEPR, resource ); 87 } 88 finally 89 { 90 MembershipContentRuleContext.setFactoryEPR( null ); 91 MembershipContentRuleContext.setRegistryEPR( null ); 92 } 93 } 94 95 /** 96 * Initializes the service group. 97 * 98 * @throws SoapFault 99 * indicates a initialization error 100 * 101 * @see org.apache.muse.ws.resource.sg.impl.SimpleServiceGroup#initialize() 102 */ 103 public void initialize() throws SoapFault 104 { 105 super.initialize(); 106 SerializerRegistry registry = SerializerRegistry.getInstance(); 107 registry.registerSerializer( MembershipContentRule.class, 108 new AgreementMembershipContentRuleSerializer() ); 109 } 110 111 }