Author: ips Date: Fri Jan 21 17:15:03 2005 New Revision: 125990 URL: http://svn.apache.org/viewcvs?view=rev&rev=125990 Log: misc Added: incubator/apollo/trunk/src/java/org/apache/ws/XmlObjectWrapper.java incubator/apollo/trunk/src/java/org/apache/ws/addressing/ incubator/apollo/trunk/src/java/org/apache/ws/addressing/EndpointReference.java Modified: incubator/apollo/trunk/src/java/org/apache/ws/resource/AbstractPortType.java incubator/apollo/trunk/src/java/org/apache/ws/resource/impl/AbstractResourceHome.java incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/ResourcePropertyCallback.java incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/SetResourcePropertyCallback.java incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySet.java incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/query/impl/XmlBeansQueryExpression.java incubator/apollo/trunk/src/java/org/apache/ws/util/XmlBeanUtils.java
Added: incubator/apollo/trunk/src/java/org/apache/ws/XmlObjectWrapper.java Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/XmlObjectWrapper.java?view=auto&rev=125990 ============================================================================== --- (empty file) +++ incubator/apollo/trunk/src/java/org/apache/ws/XmlObjectWrapper.java Fri Jan 21 17:15:03 2005 @@ -0,0 +1,30 @@ +/*=============================================================================* + * Copyright 2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *=============================================================================*/ +package org.apache.ws; + +import org.apache.xmlbeans.XmlObject; + +/** + * A wrapper for an [EMAIL PROTECTED] XmlObject}. + * + * @author Ian Springer (ian DOT springer AT hp DOT com) + */ +public interface XmlObjectWrapper +{ + + XmlObject getXmlObject(); + +} Added: incubator/apollo/trunk/src/java/org/apache/ws/addressing/EndpointReference.java Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/addressing/EndpointReference.java?view=auto&rev=125990 ============================================================================== --- (empty file) +++ incubator/apollo/trunk/src/java/org/apache/ws/addressing/EndpointReference.java Fri Jan 21 17:15:03 2005 @@ -0,0 +1,28 @@ +/*=============================================================================* + * Copyright 2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *=============================================================================*/ +package org.apache.ws.addressing; + +/** + * TODO + * + * @author Ian Springer (ian DOT springer AT hp DOT com) + */ +public interface EndpointReference +{ + + // TODO + +} Modified: incubator/apollo/trunk/src/java/org/apache/ws/resource/AbstractPortType.java Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/resource/AbstractPortType.java?view=diff&rev=125990&p1=incubator/apollo/trunk/src/java/org/apache/ws/resource/AbstractPortType.java&r1=125989&p2=incubator/apollo/trunk/src/java/org/apache/ws/resource/AbstractPortType.java&r2=125990 ============================================================================== --- incubator/apollo/trunk/src/java/org/apache/ws/resource/AbstractPortType.java (original) +++ incubator/apollo/trunk/src/java/org/apache/ws/resource/AbstractPortType.java Fri Jan 21 17:15:03 2005 @@ -80,9 +80,9 @@ { throw new JAXRPCException( re ); } - catch ( ResourceContextException e ) + catch ( ResourceContextException rce ) { - e.printStackTrace( ); //To change body of catch statement use File | Settings | File Templates. + rce.printStackTrace( ); } } Modified: incubator/apollo/trunk/src/java/org/apache/ws/resource/impl/AbstractResourceHome.java Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/resource/impl/AbstractResourceHome.java?view=diff&rev=125990&p1=incubator/apollo/trunk/src/java/org/apache/ws/resource/impl/AbstractResourceHome.java&r1=125989&p2=incubator/apollo/trunk/src/java/org/apache/ws/resource/impl/AbstractResourceHome.java&r2=125990 ============================================================================== --- incubator/apollo/trunk/src/java/org/apache/ws/resource/impl/AbstractResourceHome.java (original) +++ incubator/apollo/trunk/src/java/org/apache/ws/resource/impl/AbstractResourceHome.java Fri Jan 21 17:15:03 2005 @@ -283,7 +283,7 @@ * * @return DOCUMENT_ME * - * @throws ResourceException DOCUMENT_ME + * @throws ResourceException if * @throws InvalidResourceKeyException DOCUMENT_ME */ public Resource find( ResourceKey key ) Modified: incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/ResourcePropertyCallback.java Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/ResourcePropertyCallback.java?view=diff&rev=125990&p1=incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/ResourcePropertyCallback.java&r1=125989&p2=incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/ResourcePropertyCallback.java&r2=125990 ============================================================================== --- incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/ResourcePropertyCallback.java (original) +++ incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/ResourcePropertyCallback.java Fri Jan 21 17:15:03 2005 @@ -20,8 +20,6 @@ * on the managed resource may change. Register the callback by calling * [EMAIL PROTECTED] ResourceProperty#setCallback(ResourcePropertyCallback)} on the * property. - * - * @author Ian Springer (Hewlett-Packard Company) */ public interface ResourcePropertyCallback { Modified: incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/SetResourcePropertyCallback.java Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/SetResourcePropertyCallback.java?view=diff&rev=125990&p1=incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/SetResourcePropertyCallback.java&r1=125989&p2=incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/SetResourcePropertyCallback.java&r2=125990 ============================================================================== --- incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/SetResourcePropertyCallback.java (original) +++ incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/SetResourcePropertyCallback.java Fri Jan 21 17:15:03 2005 @@ -23,8 +23,6 @@ * Register the callback by calling * [EMAIL PROTECTED] ResourceProperty#setCallback(ResourcePropertyCallback)} on the * property. - * - * @author Ian Springer (Hewlett-Packard Company) */ public interface SetResourcePropertyCallback extends ResourcePropertyCallback { @@ -37,14 +35,14 @@ /** * - * @param prop + * @param propElems */ - void insertProperty( Object[] prop ); + void insertProperty( Object[] propElems ); /** * - * @param prop + * @param propElems */ - void updateProperty( Object[] prop ); + void updateProperty( Object[] propElems ); } Modified: incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySet.java Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySet.java?view=diff&rev=125990&p1=incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySet.java&r1=125989&p2=incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySet.java&r2=125990 ============================================================================== --- incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySet.java (original) +++ incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySet.java Fri Jan 21 17:15:03 2005 @@ -38,8 +38,10 @@ import java.lang.reflect.Method; import java.util.Collection; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.Map; +import java.util.Set; /** * LOG-DONE An Apache XMLBeans-based implementation of a resource property set. @@ -67,15 +69,27 @@ public XmlBeansResourcePropertySet( XmlObject propsDocXBean ) throws MetaDataViolationException { + this( propsDocXBean, null ); + } + + /** + * Creates a new [EMAIL PROTECTED] XmlBeansResourcePropertySet} object. + * + * @param propsDocXBean DOCUMENT_ME + * @param readOnlyPropNames names of any properties that should be made read-only + */ + public XmlBeansResourcePropertySet( XmlObject propsDocXBean, QName[] readOnlyPropNames ) + throws MetaDataViolationException + { if ( !XmlBeanUtils.isDocument( propsDocXBean ) ) { - throw new IllegalArgumentException( MSG.getMessage( Keys.XMLOBJECT_DOC, propsDocXBean.getClass().getName() ) ); + throw new IllegalArgumentException( + MSG.getMessage( Keys.XMLOBJECT_DOC, propsDocXBean.getClass().getName() ) ); } - m_propsDocXBean = propsDocXBean; m_propsXBean = getPropsDocRootElem(); m_metaData = new XmlBeansResourcePropertySetMetaData( m_propsDocXBean.schemaType() ); - initProperties(); + initProperties( readOnlyPropNames ); } /** @@ -134,7 +148,8 @@ if ( m_propsMap.containsKey( prop.getMetaData().getName() ) ) { - throw new MetaDataViolationException( MSG.getMessage( Keys.PROP_DOC_ALREADY_CONTAINS_PROPERTY, prop.getMetaData().getName() ) ); + throw new MetaDataViolationException( + MSG.getMessage( Keys.PROP_DOC_ALREADY_CONTAINS_PROPERTY, prop.getMetaData().getName() ) ); } addProperty( prop ); @@ -318,18 +333,33 @@ this ); } - private void initProperties() + private void initProperties( QName[] readOnlyPropNames ) throws MetaDataViolationException { + Set readOnlyPropNameSet = toSet( readOnlyPropNames ); SchemaProperty[] propElemDefs = m_propsXBean.schemaType().getElementProperties(); for ( int i = 0; i < propElemDefs.length; i++ ) { - XmlBeansResourceProperty prop = createProperty( propElemDefs[i], false ); + XmlBeansResourceProperty prop = createProperty( propElemDefs[i], + readOnlyPropNameSet.contains( propElemDefs[i].getName() ) ); populateProperty( prop ); addPropertyToMap( prop ); } } + private static Set toSet( Object[] array ) + { + Set set = new HashSet(); + if ( array != null ) + { + for ( int i = 0; i < array.length; i++ ) + { + set.add( array[i] ); + } + } + return set; + } + private void populateProperty( XmlBeansResourceProperty prop ) throws MetaDataViolationException { @@ -350,7 +380,8 @@ String propsElemJavaPropName = m_propsDocXBean.schemaType().getElementProperties()[0].getJavaPropertyName(); try { - Method addNewMethod = m_propsDocXBean.getClass().getMethod( "addNew" + propsElemJavaPropName, new Class[0] ); + Method addNewMethod = m_propsDocXBean.getClass().getMethod( "addNew" + propsElemJavaPropName, + new Class[0] ); propsXBean = (XmlObject) addNewMethod.invoke( m_propsDocXBean, new Object[0] ); } catch ( Exception e ) Modified: incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/query/impl/XmlBeansQueryExpression.java Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/query/impl/XmlBeansQueryExpression.java?view=diff&rev=125990&p1=incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/query/impl/XmlBeansQueryExpression.java&r1=125989&p2=incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/query/impl/XmlBeansQueryExpression.java&r2=125990 ============================================================================== --- incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/query/impl/XmlBeansQueryExpression.java (original) +++ incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/query/impl/XmlBeansQueryExpression.java Fri Jan 21 17:15:03 2005 @@ -16,11 +16,12 @@ package org.apache.ws.resource.properties.query.impl; import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.Log; -import org.apache.ws.resource.properties.query.QueryExpression; -import org.apache.ws.resource.i18n.MessagesImpl; +import org.apache.commons.logging.LogFactory; +import org.apache.ws.XmlObjectWrapper; import org.apache.ws.resource.i18n.Keys; +import org.apache.ws.resource.i18n.MessagesImpl; +import org.apache.ws.resource.properties.query.QueryExpression; import org.apache.ws.util.JaxpUtils; import org.apache.ws.util.XmlBeanUtils; import org.apache.ws.util.i18n.Messages; @@ -30,105 +31,116 @@ import org.w3c.dom.DocumentFragment; import org.w3c.dom.Node; import org.w3c.dom.Text; -import javax.naming.directory.SchemaViolationException; + import javax.xml.rpc.JAXRPCException; import java.net.URI; /** * LOG-DONE + * * @author Ian P. Springer */ public class XmlBeansQueryExpression - implements QueryExpression + implements QueryExpression, XmlObjectWrapper { - private static final Log LOG = LogFactory.getLog( XmlBeansQueryExpression.class ); - public static final Messages MSG = MessagesImpl.getInstance(); - private URI m_dialect; - private Node m_content; - - /** - * Creates a new [EMAIL PROTECTED] XmlBeansQueryExpression} object. - * - * @param queryExprXBean DOCUMENT_ME - * - * @throws SchemaViolationException DOCUMENT_ME - * @throws JAXRPCException DOCUMENT_ME - */ - public XmlBeansQueryExpression( QueryExpressionType queryExprXBean ) - throws SchemaViolationException - { - try - { - m_dialect = new URI( queryExprXBean.getDialect( ) ); - } - catch ( Exception e ) - { - throw new JAXRPCException( MSG.getMessage( Keys.FAILED_INIT_DIALECT, e )); - } - - XmlObject[] childElems = XmlBeanUtils.getChildElements( queryExprXBean ); - if ( childElems.length > 1 ) - { - throw new SchemaViolationException( MSG.getMessage( Keys.QUERY_ONLY_ONE_NODE) ); - } - - if ( childElems.length == 1 ) - { - m_content = ( (DocumentFragment) childElems[0].newDomNode( ) ).getFirstChild( ); - } - else - { - Node queryExprNode = ( (DocumentFragment) queryExprXBean.newDomNode(new XmlOptions().setSaveOuter() ) ).getFirstChild( ); - m_content = queryExprNode.getFirstChild( ); - if ( ( m_content == null ) || !( m_content instanceof Text ) ) - { - throw new SchemaViolationException( MSG.getMessage( Keys.QUERY_MUST_HAVE_ELEM_OR_TXT) ); - } - } - if(LOG.isDebugEnabled()) - { - LOG.debug(MSG.getMessage( Keys.QUERY_EXPR,toString())); - } - } - - /** - * DOCUMENT_ME - * - * @return DOCUMENT_ME - */ - public Node getContent( ) - { - return m_content; - } - - /** - * DOCUMENT_ME - * - * @return DOCUMENT_ME - */ - public URI getDialect( ) - { - return m_dialect; - } - - /** - * DOCUMENT_ME - * - * @return DOCUMENT_ME - */ - public String toString( ) - { - String contentString; - try - { - contentString = JaxpUtils.toString( m_content ); - } - catch ( Exception e ) - { - contentString = MSG.getMessage( Keys.NAME) +"=" + m_content.getNodeName( ) + ", "+ MSG.getMessage( Keys.VALUE)+"=" + m_content.getNodeValue( ); - } - - return new ToStringBuilder( this ).append( MSG.getMessage( Keys.DIALECT), m_dialect ).append( MSG.getMessage( Keys.CONTENT), contentString ) - .toString( ); - } + private static final Log LOG = LogFactory.getLog( XmlBeansQueryExpression.class ); + public static final Messages MSG = MessagesImpl.getInstance(); + + private QueryExpressionType m_queryExprXBean; + private URI m_dialect; + private Node m_content; + + /** + * Creates a new [EMAIL PROTECTED] XmlBeansQueryExpression} object. + * + * @param queryExprXBean DOCUMENT_ME + * + * @throws JAXRPCException DOCUMENT_ME + */ + public XmlBeansQueryExpression( QueryExpressionType queryExprXBean ) + { + m_queryExprXBean = queryExprXBean; + try + { + m_dialect = new URI( queryExprXBean.getDialect() ); + } + catch ( Exception e ) + { + throw new JAXRPCException( MSG.getMessage( Keys.FAILED_INIT_DIALECT, e ) ); + } + + XmlObject[] childElems = XmlBeanUtils.getChildElements( queryExprXBean ); + if ( childElems.length > 1 ) + { + throw new JAXRPCException( MSG.getMessage( Keys.QUERY_ONLY_ONE_NODE ) ); + } + + if ( childElems.length == 1 ) + { + m_content = ( (DocumentFragment) childElems[0].newDomNode() ).getFirstChild(); + } + else + { + Node queryExprNode = ( (DocumentFragment) queryExprXBean.newDomNode( new XmlOptions().setSaveOuter() ) ).getFirstChild(); + m_content = queryExprNode.getFirstChild(); + if ( ( m_content == null ) || !( m_content instanceof Text ) ) + { + throw new JAXRPCException( MSG.getMessage( Keys.QUERY_MUST_HAVE_ELEM_OR_TXT ) ); + } + } + if ( LOG.isDebugEnabled() ) + { + LOG.debug( MSG.getMessage( Keys.QUERY_EXPR, toString() ) ); + } + } + + /** + * DOCUMENT_ME + * + * @return DOCUMENT_ME + */ + public Node getContent() + { + return m_content; + } + + /** + * DOCUMENT_ME + * + * @return DOCUMENT_ME + */ + public URI getDialect() + { + return m_dialect; + } + + /** + * DOCUMENT_ME + * + * @return DOCUMENT_ME + */ + public String toString() + { + String contentString; + try + { + contentString = JaxpUtils.toString( m_content ); + } + catch ( Exception e ) + { + contentString = MSG.getMessage( Keys.NAME ) + "=" + m_content.getNodeName() + ", " + + MSG.getMessage( Keys.VALUE ) + + "=" + + m_content.getNodeValue(); + } + + return new ToStringBuilder( this ).append( MSG.getMessage( Keys.DIALECT ), m_dialect ).append( + MSG.getMessage( Keys.CONTENT ), contentString ) + .toString(); + } + + public XmlObject getXmlObject() + { + return m_queryExprXBean; + } } Modified: incubator/apollo/trunk/src/java/org/apache/ws/util/XmlBeanUtils.java Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/util/XmlBeanUtils.java?view=diff&rev=125990&p1=incubator/apollo/trunk/src/java/org/apache/ws/util/XmlBeanUtils.java&r1=125989&p2=incubator/apollo/trunk/src/java/org/apache/ws/util/XmlBeanUtils.java&r2=125990 ============================================================================== --- incubator/apollo/trunk/src/java/org/apache/ws/util/XmlBeanUtils.java (original) +++ incubator/apollo/trunk/src/java/org/apache/ws/util/XmlBeanUtils.java Fri Jan 21 17:15:03 2005 @@ -279,6 +279,22 @@ } /** + * Adds a child element to the specified XmlBean with the give name. + * + * @param parentXBean + * @param childName + */ + public static void addChildElement( XmlObject parentXBean, + QName childName ) + { + XmlCursor xCursor = parentXBean.newCursor(); + xCursor.toEndDoc(); + xCursor.toPrevToken(); + xCursor.insertElement( childName ); + xCursor.dispose(); + } + + /** * Removes the specifed XMLBean from its parent element. * * @param xBean an XMLBean --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
