From 1fb6a28a73ca17dbb8c4b3059db590e2f9620943 Mon Sep 17 00:00:00 2001 From: antelder Date: Wed, 3 Aug 2011 09:21:41 +0000 Subject: Correct tag name git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1153404 13f79535-47bb-0310-9956-ffa450edef68 --- .../tuscany/sca/binding/http/HTTPBinding.java | 31 --- .../sca/binding/http/HTTPBindingContext.java | 47 ---- .../sca/binding/http/HTTPBindingFactory.java | 35 --- .../tuscany/sca/binding/http/HTTPCacheContext.java | 257 --------------------- .../tuscany/sca/binding/http/HTTPHeader.java | 51 ---- .../binding/http/impl/HTTPBindingFactoryImpl.java | 36 --- .../sca/binding/http/impl/HTTPBindingImpl.java | 139 ----------- .../sca/binding/http/xml/HTTPBindingProcessor.java | 181 --------------- ...che.tuscany.sca.binding.http.HTTPBindingFactory | 19 -- ...ca.contribution.processor.StAXArtifactProcessor | 19 -- 10 files changed, 815 deletions(-) delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBinding.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBindingContext.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBindingFactory.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPCacheContext.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPHeader.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/impl/HTTPBindingFactoryImpl.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/impl/HTTPBindingImpl.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/xml/HTTPBindingProcessor.java delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.http.HTTPBindingFactory delete mode 100644 sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor (limited to 'sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src') diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBinding.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBinding.java deleted file mode 100644 index 3a749c5f29..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBinding.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.sca.binding.http; - -import org.apache.tuscany.sca.assembly.BindingRRB; - - -/** - * HTTP binding model. - * - * @version $Rev$ $Date$ -*/ -public interface HTTPBinding extends BindingRRB { -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBindingContext.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBindingContext.java deleted file mode 100644 index f7e5bac606..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBindingContext.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.sca.binding.http; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * HTTP Binding Context - * - * @version $Rev$ $Date$ - */ -public class HTTPBindingContext { - private HttpServletRequest request; - private HttpServletResponse response; - - public HttpServletRequest getHttpRequest() { - return request; - } - public void setHttpRequest(HttpServletRequest request) { - this.request = request; - } - public HttpServletResponse getHttpResponse() { - return response; - } - public void setHttpResponse(HttpServletResponse response) { - this.response = response; - } - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBindingFactory.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBindingFactory.java deleted file mode 100644 index e66896c68e..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBindingFactory.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.sca.binding.http; - -/** - * Factory for the HTTP binding model. - * - * @version $Rev$ $Date$ - */ -public interface HTTPBindingFactory { - - /** - * Creates a new HTTP binding. - * @return a new HTTP binding - */ - HTTPBinding createHTTPBinding(); - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPCacheContext.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPCacheContext.java deleted file mode 100644 index fb9242c26c..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPCacheContext.java +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.sca.binding.http; - -import java.text.SimpleDateFormat; -import java.util.Date; - -import javax.servlet.http.HttpServletRequest; - -/** - * A class to store cache settings for Atom and HTTP requests and responses. - * - * Predicates are statements that work in conjunction with - * ETags and LastModified dates to determine if a precondition - * or postcondition is satisfied. - * See HTTP specification for how predicates wrk: - * http://tools.ietf.org/html/rfc2616 - * Example predicates in HTTP include If-Match, If-None-Match, - * If-Modified-Since, If-Unmodified-Since, If-Range. - - */ -public class HTTPCacheContext { - public static final SimpleDateFormat RFC822DateFormat = new SimpleDateFormat( "EEE, dd MMM yyyy HH:mm:ss Z" ); // RFC 822 date time - - public boolean enabled; - public String eTag; - public String lastModified; - public Date lastModifiedDate; - public boolean ifModifiedSince; - public boolean ifUnmodifiedSince; - public boolean ifMatch; - public boolean ifNoneMatch; - public boolean ifRange; - - /** - * An ETag is a unique ID for an item. It changes when - * a field in the item or the update date changes. - * See HTTP specification for how ETags work: - * http://tools.ietf.org/html/rfc2616 - * @return the eTag - */ - public String getETag() { - return eTag; - } - /** - * @param tag the eTag to set - */ - public void setETag(String tag) { - eTag = tag; - enabled = true; - } - /** - * The LastModified date is the time the item was last - * changed. See HTTP specification for how ETags work: - * http://tools.ietf.org/html/rfc2616 - * @return the lastModified - */ - public String getLastModified() { - return lastModified; - } - /** - * The LastModified date is the time the item was last - * changed. See HTTP specification for how ETags work: - * http://tools.ietf.org/html/rfc2616 - * @return the lastModified - */ - public Date getLastModifiedAsDate() { - return lastModifiedDate; - } - /** - * @param lastModified the lastModified to set - */ - public void setLastModified(String lastModified) throws java.text.ParseException { - this.lastModified = lastModified; - // Catch date formatting on input to help debugging. - lastModifiedDate = RFC822DateFormat.parse( lastModified ); - enabled = true; - } - - /** - * @param lastModified the lastModified to set - */ - public void setLastModified(Date updated) { - this.lastModified = RFC822DateFormat.format( updated ); - lastModifiedDate = updated; - enabled = true; - } - - /** - * @return the ifModifedSince - */ - public boolean isIfModifiedSince() { - return ifModifiedSince; - } - /** - * @param ifModifedSince the ifModifedSince to set - */ - public void setIfModifiedSince(boolean ifModifiedSince) { - this.ifModifiedSince = ifModifiedSince; - if ( ifModifiedSince ) - enabled = true; - } - /** - * @return the ifUnModifiedSince - */ - public boolean isIfUnmodifiedSince() { - return ifUnmodifiedSince; - } - /** - * @param ifUnModifiedSince the ifUnModifiedSince to set - */ - public void setIfUnmodifiedSince(boolean ifUnmodifiedSince) { - this.ifUnmodifiedSince = ifUnmodifiedSince; - if ( ifUnmodifiedSince ) - enabled = true; - } - /** - * @return the ifMatch - */ - public boolean isIfMatch() { - return ifMatch; - } - /** - * @param ifMatch the ifMatch to set - */ - public void setIfMatch(boolean ifMatch) { - this.ifMatch = ifMatch; - if ( ifMatch ) - enabled = true; - } - /** - * @return the ifNoneMatch - */ - public boolean isIfNoneMatch() { - return ifNoneMatch; - } - /** - * @param ifNoneMatch the ifNoneMatch to set - */ - public void setIfNoneMatch(boolean ifNoneMatch) { - this.ifNoneMatch = ifNoneMatch; - if ( ifNoneMatch ) - enabled = true; - } - /** - * @return the ifRange - */ - public boolean isIfRange() { - return ifRange; - } - /** - * @param ifRange the ifRange to set - */ - public void setIfRange(boolean ifRange) { - this.ifRange = ifRange; - if ( ifRange ) - enabled = true; - } - - public String toString() { - final String PREDPREFIX = ", predicates="; - StringBuffer sb = new StringBuffer(PREDPREFIX); - if ( ifMatch || ifNoneMatch || ifModifiedSince || ifUnmodifiedSince || ifRange ) { - if ( ifMatch ) { - if ( sb.length() > PREDPREFIX.length() ) sb.append( ", "); - sb.append("If-Match"); - } - if ( ifNoneMatch ) { - if ( sb.length() > PREDPREFIX.length() ) sb.append( ", "); - sb.append("If-None-Match"); - } - if ( ifModifiedSince ) { - if ( sb.length() > PREDPREFIX.length() ) sb.append( ", "); - sb.append("If-Modified-Since"); - } - if ( ifUnmodifiedSince ) { - if ( sb.length() > PREDPREFIX.length() ) sb.append( ", "); - sb.append("If-UnModified-Since"); - } - if ( ifRange ) { - if ( sb.length() > PREDPREFIX.length() ) sb.append( ", "); - sb.append("If-Range"); - } - } else { - sb.append("null"); - } - - return "eTag=" + eTag + ", lastModified=" + lastModified - + sb.toString(); - } - - /** - * Gets the cache context information (ETag, LastModified, predicates) from the Http request. - * @param request - * @return - */ - public static HTTPCacheContext getCacheContextFromRequest( HttpServletRequest request ) throws java.text.ParseException { - HTTPCacheContext context = new HTTPCacheContext(); - - String eTag = request.getHeader( "If-Match" ); - if ( eTag != null ) { - context.setETag( eTag ); - context.setIfMatch( true ); - } - eTag = request.getHeader( "If-None-Match" ); - if ( eTag != null ) { - context.setETag( eTag ); - context.setIfNoneMatch( true ); - } - String lastModifiedString = request.getHeader( "If-Modified-Since" ); - if ( lastModifiedString != null ) { - context.setLastModified( lastModifiedString ); - context.setIfModifiedSince( true ); - } - lastModifiedString = request.getHeader( "If-Unmodified-Since" ); - if ( lastModifiedString != null ) { - context.setLastModified( lastModifiedString ); - context.setIfUnmodifiedSince( true ); - } - lastModifiedString = request.getHeader( "If-Range" ); - if ( lastModifiedString != null ) { - context.setLastModified( lastModifiedString ); - context.setIfRange( true ); - } - return context; - } - /** - * Enabled is true whenever ETag, LastModified, or predicate is set. - * @return the enabled - */ - public boolean isEnabled() { - return enabled; - } - /** - * @param enabled the enabled to set - */ - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPHeader.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPHeader.java deleted file mode 100644 index 69e44cf35c..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPHeader.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.sca.binding.http; - -public class HTTPHeader { - private String name; - private Object value; - - public HTTPHeader() { - - } - - public HTTPHeader(String name, Object value) { - this.name = name; - this.value = value; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Object getValue() { - return value; - } - - public void setValue(Object value) { - this.value = value; - } - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/impl/HTTPBindingFactoryImpl.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/impl/HTTPBindingFactoryImpl.java deleted file mode 100644 index 678cd1a426..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/impl/HTTPBindingFactoryImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.sca.binding.http.impl; - -import org.apache.tuscany.sca.binding.http.HTTPBinding; -import org.apache.tuscany.sca.binding.http.HTTPBindingFactory; - -/** - * Factory for the HTTP binding model. - * - * @version $Rev$ $Date$ - */ -public class HTTPBindingFactoryImpl implements HTTPBindingFactory { - - public HTTPBinding createHTTPBinding() { - return new HTTPBindingImpl(); - } - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/impl/HTTPBindingImpl.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/impl/HTTPBindingImpl.java deleted file mode 100644 index c902797a79..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/impl/HTTPBindingImpl.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.sca.binding.http.impl; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.sca.assembly.OperationSelector; -import org.apache.tuscany.sca.assembly.WireFormat; -import org.apache.tuscany.sca.binding.http.HTTPBinding; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.IntentAttachPointType; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySetAttachPoint; - - -/** - * Implementation of the HTTP binding model. - * - * @version $Rev$ $Date$ - */ -class HTTPBindingImpl implements HTTPBinding, PolicySetAttachPoint { - - private String name; - private String uri; - - private WireFormat wireFormat; - private OperationSelector operationSelector; - - private List requiredIntents = new ArrayList(); - private List policySets = new ArrayList(); - private IntentAttachPointType intentAttachPointType; - private List applicablePolicySets = new ArrayList(); - - - public String getName() { - return name; - } - - public String getURI() { - return uri; - } - - public void setName(String name) { - this.name = name; - } - - public void setURI(String uri) { - this.uri = uri; - } - - - public boolean isUnresolved() { - return false; - } - - public void setUnresolved(boolean unresolved) { - // The sample binding is always resolved - } - -// Wireformat and Operation selection - - public WireFormat getRequestWireFormat() { - return wireFormat; - } - - public void setRequestWireFormat(WireFormat wireFormat) { - this.wireFormat = wireFormat; - } - - public WireFormat getResponseWireFormat() { - return wireFormat; - } - - public void setResponseWireFormat(WireFormat wireFormat) { - this.wireFormat = wireFormat; - } - - public OperationSelector getOperationSelector() { - return operationSelector; - } - - public void setOperationSelector(OperationSelector operationSelector) { - this.operationSelector = operationSelector; - } - - //Policy related getters/setters - - public List getPolicySets() { - return policySets; - } - - public List getRequiredIntents() { - return requiredIntents; - } - - public IntentAttachPointType getType() { - return intentAttachPointType; - } - - public void setType(IntentAttachPointType intentAttachPointType) { - this.intentAttachPointType = intentAttachPointType; - } - - public void setPolicySets(List policySets) { - this.policySets = policySets; - } - - public void setRequiredIntents(List intents) { - this.requiredIntents = intents; - } - - public List getApplicablePolicySets() { - return applicablePolicySets; - } - - @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/xml/HTTPBindingProcessor.java b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/xml/HTTPBindingProcessor.java deleted file mode 100644 index cdd5c0d992..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/xml/HTTPBindingProcessor.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.sca.binding.http.xml; - -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; -import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.tuscany.sca.assembly.OperationSelector; -import org.apache.tuscany.sca.assembly.WireFormat; -import org.apache.tuscany.sca.assembly.xml.Constants; -import org.apache.tuscany.sca.assembly.xml.PolicyAttachPointProcessor; -import org.apache.tuscany.sca.binding.http.HTTPBinding; -import org.apache.tuscany.sca.binding.http.HTTPBindingFactory; -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.contribution.service.ContributionReadException; -import org.apache.tuscany.sca.contribution.service.ContributionResolveException; -import org.apache.tuscany.sca.contribution.service.ContributionWriteException; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.monitor.Monitor; -import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.monitor.Problem.Severity; -import org.apache.tuscany.sca.monitor.impl.ProblemImpl; -import org.apache.tuscany.sca.policy.PolicyFactory; - -public class HTTPBindingProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor { - private static final String BINDING_HTTP = "binding.http"; - private static final QName BINDING_HTTP_QNAME = new QName(Constants.SCA10_TUSCANY_NS, BINDING_HTTP); - - private static final String NAME = "name"; - private static final String URI = "uri"; - - private HTTPBindingFactory httpBindingFactory; - private StAXArtifactProcessor extensionProcessor; - private StAXAttributeProcessor extensionAttributeProcessor; - private PolicyFactory policyFactory; - private PolicyAttachPointProcessor policyProcessor; - private Monitor monitor; - - public HTTPBindingProcessor(ExtensionPointRegistry extensionPoints, - StAXArtifactProcessor extensionProcessor, - StAXAttributeProcessor extensionAttributeProcessor, - Monitor monitor) { - ModelFactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); - this.httpBindingFactory = modelFactories.getFactory(HTTPBindingFactory.class); - this.extensionProcessor = (StAXArtifactProcessor)extensionProcessor; - this.extensionAttributeProcessor = extensionAttributeProcessor; - this.policyFactory = modelFactories.getFactory(PolicyFactory.class); - this.policyProcessor = new PolicyAttachPointProcessor(policyFactory); - this.monitor = monitor; - } - - public QName getArtifactType() { - return BINDING_HTTP_QNAME; - } - - public Class getModelType() { - return HTTPBinding.class; - } - - public HTTPBinding read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { - HTTPBinding httpBinding = httpBindingFactory.createHTTPBinding(); - - // Read policies - policyProcessor.readPolicies(httpBinding, reader); - - while(reader.hasNext()) { - QName elementName = null; - int event = reader.getEventType(); - switch (event) { - case START_ELEMENT: - elementName = reader.getName(); - - if (BINDING_HTTP_QNAME.equals(elementName)) { - String name = getString(reader, NAME); - if(name != null) { - httpBinding.setName(name); - } - - String uri = getString(reader, URI); - if (uri != null) { - httpBinding.setURI(uri); - } - } else { - // Read an extension element - Object extension = extensionProcessor.read(reader); - if (extension != null) { - if (extension instanceof WireFormat) { - httpBinding.setRequestWireFormat((WireFormat)extension); - } else if(extension instanceof OperationSelector) { - httpBinding.setOperationSelector((OperationSelector)extension); - } - } - } - - } - - if (event == END_ELEMENT && BINDING_HTTP_QNAME.equals(reader.getName())) { - break; - } - - // Read the next element - if (reader.hasNext()) { - reader.next(); - } - } - - return httpBinding; - } - - public void write(HTTPBinding httpBinding, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { - writeStart(writer, BINDING_HTTP_QNAME.getNamespaceURI(), BINDING_HTTP_QNAME.getLocalPart()); - - //write policies - policyProcessor.writePolicyAttributes(httpBinding, writer); - - // Write binding name - if (httpBinding.getName() != null) { - writer.writeAttribute(NAME, httpBinding.getName()); - } - - // Write binding URI - if (httpBinding.getURI() != null) { - writer.writeAttribute(URI, httpBinding.getURI()); - } - - if ( httpBinding.getRequestWireFormat() != null ) { - extensionProcessor.write(httpBinding.getRequestWireFormat(), writer); - } - - if ( httpBinding.getOperationSelector() != null ) { - extensionProcessor.write(httpBinding.getOperationSelector(), writer); - } - writeEnd(writer); - } - - - public void resolve(HTTPBinding model, ModelResolver resolver) throws ContributionResolveException { - policyProcessor.resolvePolicies(model, resolver); - } - - /** - * Report a error. - * - * @param problems - * @param message - * @param model - */ - private void error(String message, Object model, Object... messageParameters) { - if (monitor != null) { - Problem problem = new ProblemImpl(this.getClass().getName(), "binding-http-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters); - monitor.problem(problem); - } - } - -} diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.http.HTTPBindingFactory b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.http.HTTPBindingFactory deleted file mode 100644 index 44da6b166c..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.http.HTTPBindingFactory +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -# Implementation class for model factory -org.apache.tuscany.sca.binding.http.impl.HTTPBindingFactoryImpl diff --git a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor deleted file mode 100644 index ac004e826a..0000000000 --- a/sca-java-1.x/tags/1.6.1-TUSCANY-3909/binding-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. - -# Implementation class for the artifact processor extension -org.apache.tuscany.sca.binding.http.xml.HTTPBindingProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#binding.http,model=org.apache.tuscany.sca.binding.http.HTTPBinding,factory=org.apache.tuscany.sca.binding.http.HTTPBindingFactory -- cgit v1.2.3