summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.5.1/modules/binding-http/src/main/java
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-11-11 23:14:18 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-11-11 23:14:18 +0000
commitfdd5b43d3c139cf2cbd1655d2efbfaf9032a5b5e (patch)
treebcd16e19fa4bbd45f956812be8b65f7a143b573f /branches/sca-java-1.5.1/modules/binding-http/src/main/java
parent3caf8614f25d6b1962e20331fdf423c863bc02f3 (diff)
Moving 1.x branches
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835145 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.5.1/modules/binding-http/src/main/java')
-rw-r--r--branches/sca-java-1.5.1/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBinding.java31
-rw-r--r--branches/sca-java-1.5.1/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBindingContext.java47
-rw-r--r--branches/sca-java-1.5.1/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBindingFactory.java35
-rw-r--r--branches/sca-java-1.5.1/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPCacheContext.java257
-rw-r--r--branches/sca-java-1.5.1/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPHeader.java51
-rw-r--r--branches/sca-java-1.5.1/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/impl/HTTPBindingFactoryImpl.java36
-rw-r--r--branches/sca-java-1.5.1/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/impl/HTTPBindingImpl.java139
-rw-r--r--branches/sca-java-1.5.1/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/xml/HTTPBindingProcessor.java181
8 files changed, 0 insertions, 777 deletions
diff --git a/branches/sca-java-1.5.1/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBinding.java b/branches/sca-java-1.5.1/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBinding.java
deleted file mode 100644
index 3a749c5f29..0000000000
--- a/branches/sca-java-1.5.1/modules/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/branches/sca-java-1.5.1/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBindingContext.java b/branches/sca-java-1.5.1/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBindingContext.java
deleted file mode 100644
index f7e5bac606..0000000000
--- a/branches/sca-java-1.5.1/modules/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/branches/sca-java-1.5.1/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBindingFactory.java b/branches/sca-java-1.5.1/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBindingFactory.java
deleted file mode 100644
index e66896c68e..0000000000
--- a/branches/sca-java-1.5.1/modules/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/branches/sca-java-1.5.1/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPCacheContext.java b/branches/sca-java-1.5.1/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPCacheContext.java
deleted file mode 100644
index fb9242c26c..0000000000
--- a/branches/sca-java-1.5.1/modules/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/branches/sca-java-1.5.1/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPHeader.java b/branches/sca-java-1.5.1/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPHeader.java
deleted file mode 100644
index 69e44cf35c..0000000000
--- a/branches/sca-java-1.5.1/modules/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/branches/sca-java-1.5.1/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/impl/HTTPBindingFactoryImpl.java b/branches/sca-java-1.5.1/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/impl/HTTPBindingFactoryImpl.java
deleted file mode 100644
index 678cd1a426..0000000000
--- a/branches/sca-java-1.5.1/modules/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/branches/sca-java-1.5.1/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/impl/HTTPBindingImpl.java b/branches/sca-java-1.5.1/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/impl/HTTPBindingImpl.java
deleted file mode 100644
index c902797a79..0000000000
--- a/branches/sca-java-1.5.1/modules/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<Intent> requiredIntents = new ArrayList<Intent>();
- private List<PolicySet> policySets = new ArrayList<PolicySet>();
- private IntentAttachPointType intentAttachPointType;
- private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
-
-
- 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<PolicySet> getPolicySets() {
- return policySets;
- }
-
- public List<Intent> getRequiredIntents() {
- return requiredIntents;
- }
-
- public IntentAttachPointType getType() {
- return intentAttachPointType;
- }
-
- public void setType(IntentAttachPointType intentAttachPointType) {
- this.intentAttachPointType = intentAttachPointType;
- }
-
- public void setPolicySets(List<PolicySet> policySets) {
- this.policySets = policySets;
- }
-
- public void setRequiredIntents(List<Intent> intents) {
- this.requiredIntents = intents;
- }
-
- public List<PolicySet> getApplicablePolicySets() {
- return applicablePolicySets;
- }
-
- @Override
- public Object clone() throws CloneNotSupportedException {
- return super.clone();
- }
-
-}
diff --git a/branches/sca-java-1.5.1/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/xml/HTTPBindingProcessor.java b/branches/sca-java-1.5.1/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/xml/HTTPBindingProcessor.java
deleted file mode 100644
index cb35d0f104..0000000000
--- a/branches/sca-java-1.5.1/modules/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<HTTPBinding> {
- 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<Object> extensionProcessor;
- private StAXAttributeProcessor<Object> 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<Object>)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<HTTPBinding> 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);
- }
- }
-
-}