From portal-commits at lists.jboss.org Tue Nov 21 21:16:24 2006 Content-Type: multipart/mixed; boundary="===============4572564566654690708==" MIME-Version: 1.0 From: portal-commits at lists.jboss.org To: portal-commits at lists.jboss.org Subject: [portal-commits] JBoss Portal SVN: r5707 - in trunk/wsrp/src: main/org/jboss/portal/test/wsrp/deployment main/org/jboss/portal/wsrp/deployment main/org/jboss/portal/wsrp/producer/registration/api main/org/jboss/portal/wsrp/producer/registration/impl resources/tests/test-deployment-lib-jar Date: Tue, 21 Nov 2006 21:16:23 -0500 Message-ID: --===============4572564566654690708== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: chris.laprun(a)jboss.com Date: 2006-11-21 21:16:17 -0500 (Tue, 21 Nov 2006) New Revision: 5707 Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTest= Case.java trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFacto= ry.java trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/Loca= lizedString.java trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/Prod= ucerRegistrationRequirements.java trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/Regi= strationPropertyDescription.java trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/Pro= ducerRegistrationRequirementsImpl.java trunk/wsrp/src/resources/tests/test-deployment-lib-jar/test-wsrp.xml Log: - Added support for adding required registration information to the produce= r. - Updated DeploymentTestCase and test data. Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/Deploym= entTestCase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTes= tCase.java 2006-11-21 21:51:07 UTC (rev 5706) +++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTes= tCase.java 2006-11-22 02:16:17 UTC (rev 5707) @@ -30,6 +30,9 @@ import org.jboss.portal.wsrp.deployment.WSRPConsumerService; import org.jboss.portal.wsrp.deployment.WSRPDeployment; import org.jboss.portal.wsrp.deployment.WSRPDeploymentFactory; +import org.jboss.portal.wsrp.producer.registration.api.LocalizedString; +import org.jboss.portal.wsrp.producer.registration.api.ProducerRegistratio= nRequirements; +import org.jboss.portal.wsrp.producer.registration.api.RegistrationPropert= yDescription; import org.jboss.portal.wsrp.services.PerEndpointSOAPInvokerServiceFactory; import org.jboss.portal.wsrp.services.RemoteSOAPInvokerServiceFactory; import org.jboss.portal.wsrp.services.ServiceFactory; @@ -37,8 +40,11 @@ import org.jboss.xb.binding.Unmarshaller; import org.jboss.xb.binding.UnmarshallerFactory; = +import javax.xml.namespace.QName; import java.net.URL; import java.util.List; +import java.util.Locale; +import java.util.Map; = /** * @author Julien Viet @@ -61,7 +67,7 @@ WSRPDeployment deployment =3D (WSRPDeployment)o; List services =3D deployment.getServices(); assertNotNull(services); - assertEquals(4, services.size()); + assertEquals(5, services.size()); = // Object service =3D services.get(0); @@ -125,6 +131,34 @@ assertNotNull(registrationData); assertNotNull(registrationData.getConsumerName()); assertEquals(WSRPConstants.CONSUMER_AGENT, registrationData.getConsu= merAgent()); + + ProducerRegistrationRequirements requirements =3D (ProducerRegistrat= ionRequirements)services.get(4); + assertTrue(requirements.requiresRegistration()); + assertTrue(requirements.fullServiceDescriptionRequiresRegistration()= ); + Map properties =3D requirements.getRegistrationProperties(); + assertNotNull(properties); + assertEquals(2, properties.size()); + + checkRegistrationProperty(requirements, 1); + checkRegistrationProperty(requirements, 2); } = + private void checkRegistrationProperty(ProducerRegistrationRequirements= requirements, int index) + { + RegistrationPropertyDescription desc =3D requirements.getRegistratio= nPropertyWith("name" + index); + assertNotNull(desc); + assertEquals(new QName("name" + index), desc.getName()); + assertEquals(new QName("xsd:string"), desc.getType()); + + LocalizedString localizedString =3D new LocalizedString("hint" + ind= ex, Locale.ENGLISH); + localizedString.setResourceName("resource.hint" + index); + localizedString.setValue("hint" + index); + assertEquals(localizedString, desc.getHint()); + + localizedString =3D new LocalizedString("label" + index, Locale.ENGL= ISH); + localizedString.setResourceName("resource.label" + index); + localizedString.setValue("label" + index); + assertEquals(localizedString, desc.getLabel()); + } + } Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeployme= ntFactory.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFact= ory.java 2006-11-21 21:51:07 UTC (rev 5706) +++ trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFact= ory.java 2006-11-22 02:16:17 UTC (rev 5707) @@ -22,10 +22,16 @@ *************************************************************************= *****/ package org.jboss.portal.wsrp.deployment; = +import org.jboss.portal.common.util.LocaleInfo; +import org.jboss.portal.common.util.ParameterValidation; import org.jboss.portal.wsrp.WSRPTypeFactory; import org.jboss.portal.wsrp.consumer.WSRPConsumerImpl; import org.jboss.portal.wsrp.core.Property; import org.jboss.portal.wsrp.core.RegistrationData; +import org.jboss.portal.wsrp.producer.registration.api.LocalizedString; +import org.jboss.portal.wsrp.producer.registration.api.ProducerRegistratio= nRequirements; +import org.jboss.portal.wsrp.producer.registration.api.RegistrationPropert= yDescription; +import org.jboss.portal.wsrp.producer.registration.impl.ProducerRegistrati= onRequirementsImpl; import org.jboss.portal.wsrp.services.AbstractJNDIServiceFactory; import org.jboss.portal.wsrp.services.PerEndpointSOAPInvokerServiceFactory; import org.jboss.portal.wsrp.services.RemoteSOAPInvokerServiceFactory; @@ -34,8 +40,10 @@ import org.jboss.xb.binding.UnmarshallingContext; import org.xml.sax.Attributes; = +import javax.xml.namespace.QName; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.Properties; = /** @@ -46,10 +54,13 @@ */ public class WSRPDeploymentFactory implements ObjectModelFactory { + private static final boolean DEBUG =3D false; = /** . */ private static final String WSRP_PRODUCER =3D "wsrp-producer"; = + private static final String REGISTRATION_CONFIG =3D "registration-confi= guration"; + /** . */ private List properties =3D new ArrayList(); = @@ -87,19 +98,36 @@ public Object newChild(WSRPDeployment deployment, UnmarshallingContext = nav, String nsURI, String localName, Attributes attrs) { - Object child =3D null; if (WSRP_PRODUCER.equals(localName)) { WSRPConsumerService service =3D new WSRPConsumerService(); service.setConsumer(new WSRPConsumerImpl()); - child =3D service; + return service; } - return child; + else if (REGISTRATION_CONFIG.equals(localName)) + { + ProducerRegistrationRequirements registrationRequirements =3D new= ProducerRegistrationRequirementsImpl(); + registrationRequirements.setRequiresRegistration(true); + String descRequiresRegistration =3D attrs.getValue("fullServiceDe= scriptionRequiresRegistration"); + if ("true".equals(descRequiresRegistration)) + { + registrationRequirements.setFullServiceDescriptionRequiresRegi= stration(true); + } + return registrationRequirements; + } + else + { + return null; + } } = public Object newChild(WSRPConsumerService service, UnmarshallingContex= t nav, String nsURI, String localName, Attributes attrs) { + if (DEBUG) + { + System.out.println("newchild service " + localName); + } = AbstractJNDIServiceFactory serviceFactory =3D null; RegistrationData registrationData =3D null; @@ -134,6 +162,11 @@ public Object newChild(RegistrationData registrationData, Unmarshalling= Context nav, String nsURI, String localName, Attributes attrs) { + if (DEBUG) + { + System.out.println("newChild registrationdata " + localName); + } + if ("property".equals(localName)) { return new Property(); @@ -144,6 +177,11 @@ public void setValue(WSRPConsumerService service, UnmarshallingContext = nav, String nsURI, String localName, String value) { + if (DEBUG) + { + System.out.println("setvalue service " + localName); + } + if ("producer-id".equals(localName)) { service.setId(value); @@ -165,6 +203,11 @@ public void setValue(PerEndpointSOAPInvokerServiceFactory serviceFactor= y, UnmarshallingContext nav, String nsURI, String localName, String value) { + if (DEBUG) + { + System.out.println("setvalue servicefactory " + localName); + } + if ("service-description-url".equals(localName)) { // Resolve value that may contain properties for that one @@ -203,6 +246,11 @@ public void setValue(RegistrationData registrationData, UnmarshallingCo= ntext nav, String nsURI, String localName, String value) { + if (DEBUG) + { + System.out.println("setvalue registrationdata " + localName); + } + if ("consumer-name".equals(localName)) { value =3D StringPropertyReplacer.replaceProperties(value); @@ -212,6 +260,11 @@ = public void setValue(Property property, UnmarshallingContext nav, Strin= g nsURI, String localName, String value) { + if (DEBUG) + { + System.out.println("setvalue property " + localName); + } + if ("name".equals(localName)) { value =3D StringPropertyReplacer.replaceProperties(value); @@ -232,12 +285,22 @@ public void addChild(RegistrationData registrationData, Property proper= ty, UnmarshallingContext nav, String nsURI, String localName) { + if (DEBUG) + { + System.out.println("addchild registrationdata property " + localN= ame); + } + properties.add(property); } = public void addChild(WSRPConsumerService service, RegistrationData regi= strationData, UnmarshallingContext nav, String nsURI, String localName) { + if (DEBUG) + { + System.out.println("addchild service registrationdata " + localNa= me); + } + Property[] propertyArray =3D (Property[])properties.toArray(new Prop= erty[0]); registrationData.setRegistrationProperties(propertyArray); service.getConsumer().setRegistrationData(registrationData); @@ -246,12 +309,143 @@ public void addChild(WSRPConsumerService service, PerEndpointSOAPInvoke= rServiceFactory serviceFactory, UnmarshallingContext nav, String nsURI, String loc= alName) { + if (DEBUG) + { + System.out.println("addchild service servicefactory " + localName= ); + } + service.getConsumer().setServiceFactory(serviceFactory); } = public void addChild(WSRPDeployment deployment, WSRPConsumerService ser= vice, UnmarshallingContext nav, String nsURI, String localName) { + if (DEBUG) + { + System.out.println("addchild deployment service " + localName); + } + deployment.getServices().add(service); } + + // ***** Registration requirements ***** + + public Object newChild(ProducerRegistrationRequirementsImpl regReq, Unm= arshallingContext nav, String nsURI, + String localName, Attributes attrs) + { + if (DEBUG) + { + System.out.println("newChild regReq " + localName); + } + + if ("registration-property-description".equals(localName)) + { + return new RegistrationPropertyDescription(); + } + else + { + return null; + } + } + + public void setValue(RegistrationPropertyDescription desc, Unmarshallin= gContext nav, String nsURI, + String localName, String value) + { + if (DEBUG) + { + System.out.println("setvalue desc " + localName); + } + + if ("name".equals(localName)) + { + value =3D StringPropertyReplacer.replaceProperties(value); + desc.setName(new QName(value)); + } + else if ("type".equals(localName)) + { + value =3D StringPropertyReplacer.replaceProperties(value); + desc.setType(new QName(value)); + } + } + + public Object newChild(RegistrationPropertyDescription desc, Unmarshall= ingContext nav, String nsURI, String localName, + Attributes attrs) + { + if (DEBUG) + { + System.out.println("newchild desc " + localName); + } + + if ("hint".equals(localName) || "label".equals(localName)) + { + String lang =3D attrs.getValue("xml:lang"); + ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(lang, "= xml:lang", localName); + Locale locale =3D LocaleInfo.decodeLocaleInfo(lang).getLocale(); + + String resourceName =3D attrs.getValue("resourceName"); + + LocalizedString string =3D new LocalizedString(); + string.setLocale(locale); + + if (resourceName !=3D null && resourceName.length() > 0) + { + string.setResourceName(resourceName); + } + + return string; + } + + return null; + } + + public void setValue(LocalizedString string, UnmarshallingContext nav, = String nsURI, String localName, String value) + { + if (DEBUG) + { + System.out.println("setvalue string " + localName); + } + + value =3D StringPropertyReplacer.replaceProperties(value); + string.setValue(value); + } + + public void addChild(ProducerRegistrationRequirementsImpl regReq, Regis= trationPropertyDescription desc, + UnmarshallingContext nav, String nsURI, String loc= alName) + { + if (DEBUG) + { + System.out.println("addchild regreq desc " + localName); + } + + regReq.addRegistrationProperty(desc); + } + + public void addChild(RegistrationPropertyDescription desc, LocalizedStr= ing string, UnmarshallingContext nav, + String nsURI, String localName) + { + if (DEBUG) + { + System.out.println("addchild desc string " + localName); + } + + if ("hint".equals(localName)) + { + desc.setHint(string); + } + else if ("label".equals(localName)) + { + desc.setLabel(string); + } + } + + public void addChild(WSRPDeployment deployment, ProducerRegistrationReq= uirements regReq, UnmarshallingContext nav, + String nsURI, String localName) + { + if (DEBUG) + { + System.out.println("addchild deployment regreq " + localName); + } + + deployment.getServices().add(regReq); + } } Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/a= pi/LocalizedString.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/Loc= alizedString.java 2006-11-21 21:51:07 UTC (rev 5706) +++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/Loc= alizedString.java 2006-11-22 02:16:17 UTC (rev 5707) @@ -23,6 +23,8 @@ = package org.jboss.portal.wsrp.producer.registration.api; = +import org.jboss.portal.common.util.ParameterValidation; + import java.util.Locale; = /** @@ -50,6 +52,58 @@ this.locale =3D Locale.getDefault(); } = + public LocalizedString() + { + } + + + public String toString() + { + return "LocalizedString{" + + "value=3D'" + value + '\'' + + ", locale=3D" + locale + + ", resourceName=3D'" + resourceName + '\'' + + '}'; + } + + public boolean equals(Object o) + { + if (this =3D=3D o) + { + return true; + } + if (o =3D=3D null || getClass() !=3D o.getClass()) + { + return false; + } + + LocalizedString that =3D (LocalizedString)o; + + if (!locale.equals(that.locale)) + { + return false; + } + if (resourceName !=3D null ? !resourceName.equals(that.resourceName)= : that.resourceName !=3D null) + { + return false; + } + if (value !=3D null ? !value.equals(that.value) : that.value !=3D nu= ll) + { + return false; + } + + return true; + } + + public int hashCode() + { + int result; + result =3D (value !=3D null ? value.hashCode() : 0); + result =3D 31 * result + locale.hashCode(); + result =3D 31 * result + (resourceName !=3D null ? resourceName.hash= Code() : 0); + return result; + } + public String getValue() { return value; @@ -57,6 +111,7 @@ = public void setValue(String value) { + ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(value, "va= lue", "LocalizedString"); this.value =3D value; } = @@ -67,6 +122,7 @@ = public void setLocale(Locale locale) { + ParameterValidation.throwIllegalArgExceptionIfNull(locale, "locale"); this.locale =3D locale; } = @@ -77,6 +133,7 @@ = public void setResourceName(String resourceName) { + ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(resourceNa= me, "resource name", "LocalizedString"); this.resourceName =3D resourceName; } } Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/a= pi/ProducerRegistrationRequirements.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/Pro= ducerRegistrationRequirements.java 2006-11-21 21:51:07 UTC (rev 5706) +++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/Pro= ducerRegistrationRequirements.java 2006-11-22 02:16:17 UTC (rev 5707) @@ -55,4 +55,8 @@ boolean acceptValueFor(Object value, QName propertyName); = boolean acceptValueFor(Object value, String propertyName); + + RegistrationPropertyDescription getRegistrationPropertyWith(String name= ); + + RegistrationPropertyDescription getRegistrationPropertyWith(QName name); } Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/a= pi/RegistrationPropertyDescription.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/Reg= istrationPropertyDescription.java 2006-11-21 21:51:07 UTC (rev 5706) +++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/Reg= istrationPropertyDescription.java 2006-11-22 02:16:17 UTC (rev 5707) @@ -54,6 +54,10 @@ this(new QName(name), type); } = + public RegistrationPropertyDescription() + { + } + public QName getName() { return name; Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/i= mpl/ProducerRegistrationRequirementsImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/Pr= oducerRegistrationRequirementsImpl.java 2006-11-21 21:51:07 UTC (rev 5706) +++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/Pr= oducerRegistrationRequirementsImpl.java 2006-11-22 02:16:17 UTC (rev 5707) @@ -47,8 +47,13 @@ = public ProducerRegistrationRequirementsImpl(boolean requiresMarshalling= , boolean requiresRegistration, boolean fullServiceDescriptionRequiresRegis= tration) { + this(); this.requiresRegistration =3D requiresRegistration; this.fullServiceDescriptionRequiresRegistration =3D fullServiceDescr= iptionRequiresRegistration; + } + + public ProducerRegistrationRequirementsImpl() + { registrationProperties =3D new HashMap(7); } = @@ -95,6 +100,19 @@ return acceptValueFor(value, new QName(propertyName)); } = + public RegistrationPropertyDescription getRegistrationPropertyWith(Stri= ng name) + { + ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(name, "Pro= perty name", null); + return getRegistrationPropertyWith(new QName(name)); + } + + + public RegistrationPropertyDescription getRegistrationPropertyWith(QNam= e name) + { + ParameterValidation.throwIllegalArgExceptionIfNull(name, "Property n= ame"); + return (RegistrationPropertyDescription)registrationProperties.get(n= ame); + } + private RegistrationPropertyDescription getPropertyDescription(QName pr= opertyName) { return (RegistrationPropertyDescription)registrationProperties.get(p= ropertyName); Modified: trunk/wsrp/src/resources/tests/test-deployment-lib-jar/test-wsrp.= xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/wsrp/src/resources/tests/test-deployment-lib-jar/test-wsrp.xml 20= 06-11-21 21:51:07 UTC (rev 5706) +++ trunk/wsrp/src/resources/tests/test-deployment-lib-jar/test-wsrp.xml 20= 06-11-22 02:16:17 UTC (rev 5707) @@ -78,4 +78,20 @@ + + + + name1 + xsd:string + hint1 + + + + name2 + xsd:string + hint2 + + + + \ No newline at end of file --===============4572564566654690708==--