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/DeploymentTestCase.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFactory.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/LocalizedString.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/ProducerRegistrationRequirements.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/RegistrationPropertyDescription.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ProducerRegistrationRequirementsImpl.java
trunk/wsrp/src/resources/tests/test-deployment-lib-jar/test-wsrp.xml
Log:
- Added support for adding required registration information to the producer.
- Updated DeploymentTestCase and test data.
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTestCase.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTestCase.java 2006-11-21
21:51:07 UTC (rev 5706)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTestCase.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.ProducerRegistrationRequirements;
+import org.jboss.portal.wsrp.producer.registration.api.RegistrationPropertyDescription;
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 <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -61,7 +67,7 @@
WSRPDeployment deployment = (WSRPDeployment)o;
List services = deployment.getServices();
assertNotNull(services);
- assertEquals(4, services.size());
+ assertEquals(5, services.size());
//
Object service = services.get(0);
@@ -125,6 +131,34 @@
assertNotNull(registrationData);
assertNotNull(registrationData.getConsumerName());
assertEquals(WSRPConstants.CONSUMER_AGENT, registrationData.getConsumerAgent());
+
+ ProducerRegistrationRequirements requirements =
(ProducerRegistrationRequirements)services.get(4);
+ assertTrue(requirements.requiresRegistration());
+ assertTrue(requirements.fullServiceDescriptionRequiresRegistration());
+ Map properties = requirements.getRegistrationProperties();
+ assertNotNull(properties);
+ assertEquals(2, properties.size());
+
+ checkRegistrationProperty(requirements, 1);
+ checkRegistrationProperty(requirements, 2);
}
+ private void checkRegistrationProperty(ProducerRegistrationRequirements requirements,
int index)
+ {
+ RegistrationPropertyDescription desc =
requirements.getRegistrationPropertyWith("name" + index);
+ assertNotNull(desc);
+ assertEquals(new QName("name" + index), desc.getName());
+ assertEquals(new QName("xsd:string"), desc.getType());
+
+ LocalizedString localizedString = new LocalizedString("hint" + index,
Locale.ENGLISH);
+ localizedString.setResourceName("resource.hint" + index);
+ localizedString.setValue("hint" + index);
+ assertEquals(localizedString, desc.getHint());
+
+ localizedString = new LocalizedString("label" + index, Locale.ENGLISH);
+ localizedString.setResourceName("resource.label" + index);
+ localizedString.setValue("label" + index);
+ assertEquals(localizedString, desc.getLabel());
+ }
+
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFactory.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFactory.java 2006-11-21
21:51:07 UTC (rev 5706)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFactory.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.ProducerRegistrationRequirements;
+import org.jboss.portal.wsrp.producer.registration.api.RegistrationPropertyDescription;
+import
org.jboss.portal.wsrp.producer.registration.impl.ProducerRegistrationRequirementsImpl;
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 = false;
/** . */
private static final String WSRP_PRODUCER = "wsrp-producer";
+ private static final String REGISTRATION_CONFIG =
"registration-configuration";
+
/** . */
private List properties = new ArrayList();
@@ -87,19 +98,36 @@
public Object newChild(WSRPDeployment deployment, UnmarshallingContext nav, String
nsURI, String localName,
Attributes attrs)
{
- Object child = null;
if (WSRP_PRODUCER.equals(localName))
{
WSRPConsumerService service = new WSRPConsumerService();
service.setConsumer(new WSRPConsumerImpl());
- child = service;
+ return service;
}
- return child;
+ else if (REGISTRATION_CONFIG.equals(localName))
+ {
+ ProducerRegistrationRequirements registrationRequirements = new
ProducerRegistrationRequirementsImpl();
+ registrationRequirements.setRequiresRegistration(true);
+ String descRequiresRegistration =
attrs.getValue("fullServiceDescriptionRequiresRegistration");
+ if ("true".equals(descRequiresRegistration))
+ {
+
registrationRequirements.setFullServiceDescriptionRequiresRegistration(true);
+ }
+ return registrationRequirements;
+ }
+ else
+ {
+ return null;
+ }
}
public Object newChild(WSRPConsumerService service, UnmarshallingContext nav, String
nsURI, String localName,
Attributes attrs)
{
+ if (DEBUG)
+ {
+ System.out.println("newchild service " + localName);
+ }
AbstractJNDIServiceFactory serviceFactory = null;
RegistrationData registrationData = null;
@@ -134,6 +162,11 @@
public Object newChild(RegistrationData registrationData, UnmarshallingContext 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 serviceFactory,
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, UnmarshallingContext nav,
String nsURI, String localName,
String value)
{
+ if (DEBUG)
+ {
+ System.out.println("setvalue registrationdata " + localName);
+ }
+
if ("consumer-name".equals(localName))
{
value = StringPropertyReplacer.replaceProperties(value);
@@ -212,6 +260,11 @@
public void setValue(Property property, UnmarshallingContext nav, String nsURI, String
localName, String value)
{
+ if (DEBUG)
+ {
+ System.out.println("setvalue property " + localName);
+ }
+
if ("name".equals(localName))
{
value = StringPropertyReplacer.replaceProperties(value);
@@ -232,12 +285,22 @@
public void addChild(RegistrationData registrationData, Property property,
UnmarshallingContext nav, String nsURI,
String localName)
{
+ if (DEBUG)
+ {
+ System.out.println("addchild registrationdata property " +
localName);
+ }
+
properties.add(property);
}
public void addChild(WSRPConsumerService service, RegistrationData registrationData,
UnmarshallingContext nav,
String nsURI, String localName)
{
+ if (DEBUG)
+ {
+ System.out.println("addchild service registrationdata " + localName);
+ }
+
Property[] propertyArray = (Property[])properties.toArray(new Property[0]);
registrationData.setRegistrationProperties(propertyArray);
service.getConsumer().setRegistrationData(registrationData);
@@ -246,12 +309,143 @@
public void addChild(WSRPConsumerService service, PerEndpointSOAPInvokerServiceFactory
serviceFactory,
UnmarshallingContext nav, String nsURI, String localName)
{
+ if (DEBUG)
+ {
+ System.out.println("addchild service servicefactory " + localName);
+ }
+
service.getConsumer().setServiceFactory(serviceFactory);
}
public void addChild(WSRPDeployment deployment, WSRPConsumerService service,
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,
UnmarshallingContext 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, UnmarshallingContext nav,
String nsURI,
+ String localName, String value)
+ {
+ if (DEBUG)
+ {
+ System.out.println("setvalue desc " + localName);
+ }
+
+ if ("name".equals(localName))
+ {
+ value = StringPropertyReplacer.replaceProperties(value);
+ desc.setName(new QName(value));
+ }
+ else if ("type".equals(localName))
+ {
+ value = StringPropertyReplacer.replaceProperties(value);
+ desc.setType(new QName(value));
+ }
+ }
+
+ public Object newChild(RegistrationPropertyDescription desc, UnmarshallingContext nav,
String nsURI, String localName,
+ Attributes attrs)
+ {
+ if (DEBUG)
+ {
+ System.out.println("newchild desc " + localName);
+ }
+
+ if ("hint".equals(localName) || "label".equals(localName))
+ {
+ String lang = attrs.getValue("xml:lang");
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(lang,
"xml:lang", localName);
+ Locale locale = LocaleInfo.decodeLocaleInfo(lang).getLocale();
+
+ String resourceName = attrs.getValue("resourceName");
+
+ LocalizedString string = new LocalizedString();
+ string.setLocale(locale);
+
+ if (resourceName != 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 = StringPropertyReplacer.replaceProperties(value);
+ string.setValue(value);
+ }
+
+ public void addChild(ProducerRegistrationRequirementsImpl regReq,
RegistrationPropertyDescription desc,
+ UnmarshallingContext nav, String nsURI, String localName)
+ {
+ if (DEBUG)
+ {
+ System.out.println("addchild regreq desc " + localName);
+ }
+
+ regReq.addRegistrationProperty(desc);
+ }
+
+ public void addChild(RegistrationPropertyDescription desc, LocalizedString 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, ProducerRegistrationRequirements
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/api/LocalizedString.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/LocalizedString.java 2006-11-21
21:51:07 UTC (rev 5706)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/LocalizedString.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 = Locale.getDefault();
}
+ public LocalizedString()
+ {
+ }
+
+
+ public String toString()
+ {
+ return "LocalizedString{" +
+ "value='" + value + '\'' +
+ ", locale=" + locale +
+ ", resourceName='" + resourceName + '\'' +
+ '}';
+ }
+
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ LocalizedString that = (LocalizedString)o;
+
+ if (!locale.equals(that.locale))
+ {
+ return false;
+ }
+ if (resourceName != null ? !resourceName.equals(that.resourceName) :
that.resourceName != null)
+ {
+ return false;
+ }
+ if (value != null ? !value.equals(that.value) : that.value != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (value != null ? value.hashCode() : 0);
+ result = 31 * result + locale.hashCode();
+ result = 31 * result + (resourceName != null ? resourceName.hashCode() : 0);
+ return result;
+ }
+
public String getValue()
{
return value;
@@ -57,6 +111,7 @@
public void setValue(String value)
{
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(value, "value",
"LocalizedString");
this.value = value;
}
@@ -67,6 +122,7 @@
public void setLocale(Locale locale)
{
+ ParameterValidation.throwIllegalArgExceptionIfNull(locale, "locale");
this.locale = locale;
}
@@ -77,6 +133,7 @@
public void setResourceName(String resourceName)
{
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(resourceName,
"resource name", "LocalizedString");
this.resourceName = resourceName;
}
}
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/ProducerRegistrationRequirements.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/ProducerRegistrationRequirements.java 2006-11-21
21:51:07 UTC (rev 5706)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/ProducerRegistrationRequirements.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/api/RegistrationPropertyDescription.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/RegistrationPropertyDescription.java 2006-11-21
21:51:07 UTC (rev 5706)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/RegistrationPropertyDescription.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/impl/ProducerRegistrationRequirementsImpl.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ProducerRegistrationRequirementsImpl.java 2006-11-21
21:51:07 UTC (rev 5706)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ProducerRegistrationRequirementsImpl.java 2006-11-22
02:16:17 UTC (rev 5707)
@@ -47,8 +47,13 @@
public ProducerRegistrationRequirementsImpl(boolean requiresMarshalling, boolean
requiresRegistration, boolean fullServiceDescriptionRequiresRegistration)
{
+ this();
this.requiresRegistration = requiresRegistration;
this.fullServiceDescriptionRequiresRegistration =
fullServiceDescriptionRequiresRegistration;
+ }
+
+ public ProducerRegistrationRequirementsImpl()
+ {
registrationProperties = new HashMap(7);
}
@@ -95,6 +100,19 @@
return acceptValueFor(value, new QName(propertyName));
}
+ public RegistrationPropertyDescription getRegistrationPropertyWith(String name)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(name, "Property
name", null);
+ return getRegistrationPropertyWith(new QName(name));
+ }
+
+
+ public RegistrationPropertyDescription getRegistrationPropertyWith(QName name)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(name, "Property
name");
+ return (RegistrationPropertyDescription)registrationProperties.get(name);
+ }
+
private RegistrationPropertyDescription getPropertyDescription(QName propertyName)
{
return (RegistrationPropertyDescription)registrationProperties.get(propertyName);
Modified: trunk/wsrp/src/resources/tests/test-deployment-lib-jar/test-wsrp.xml
===================================================================
--- trunk/wsrp/src/resources/tests/test-deployment-lib-jar/test-wsrp.xml 2006-11-21
21:51:07 UTC (rev 5706)
+++ trunk/wsrp/src/resources/tests/test-deployment-lib-jar/test-wsrp.xml 2006-11-22
02:16:17 UTC (rev 5707)
@@ -78,4 +78,20 @@
</registration-data>
</wsrp-producer>
</deployment>
+ <deployment>
+ <registration-configuration
fullServiceDescriptionRequiresRegistration="true">
+ <registration-property-description>
+ <name>name1</name>
+ <type>xsd:string</type>
+ <hint xml:lang="en"
resourceName="resource.hint1">hint1</hint>
+ <label xml:lang="en"
resourceName="resource.label1">label1</label>
+ </registration-property-description>
+ <registration-property-description>
+ <name>name2</name>
+ <type>xsd:string</type>
+ <hint xml:lang="en"
resourceName="resource.hint2">hint2</hint>
+ <label xml:lang="en"
resourceName="resource.label2">label2</label>
+ </registration-property-description>
+ </registration-configuration>
+ </deployment>
</deployments>
\ No newline at end of file