You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by sv...@apache.org on 2007/06/25 07:31:16 UTC
svn commit: r550354 [1/2] - in /incubator/tuscany/java/sca:
demos/alert-aggregator/src/main/java/org/apache/tuscany/sca/demos/aggregator/
modules/
modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/
modules/host-embedded/src/main/ja...
Author: svkrish
Date: Sun Jun 24 22:31:14 2007
New Revision: 550354
URL: http://svn.apache.org/viewvc?view=rev&rev=550354
Log:
fixing license headers
Added:
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/BindingType.java
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.java
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentMapQualifier.java
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/SCADefinitions.java
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapQualifierImpl.java
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/SCADefinitionsImpl.java
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/service/
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/service/DuplicateEntryException.java
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/service/EntryNotFoundException.java
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/service/PolicyService.java
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/service/impl/
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/service/impl/DefaultPolicyServiceImpl.java
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/xml/
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyIntentProcessor.java
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/xml/SCADefinitionsDocumentProcessor.java
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/xml/SCADefinitionsProcessor.java
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/xml/XAttr.java
Modified:
incubator/tuscany/java/sca/demos/alert-aggregator/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertTypeNonSDOImpl.java
incubator/tuscany/java/sca/demos/alert-aggregator/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsTypeNonSDOImpl.java
incubator/tuscany/java/sca/demos/alert-aggregator/src/main/java/org/apache/tuscany/sca/demos/aggregator/ConfigTypeNonSDOImpl.java
incubator/tuscany/java/sca/demos/alert-aggregator/src/main/java/org/apache/tuscany/sca/demos/aggregator/SourceTypeNonSDOImpl.java
incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntimeBuilder.java
incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/engines/TuscanyJRubyScriptEngine.java
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java
incubator/tuscany/java/sca/modules/pom.xml
Modified: incubator/tuscany/java/sca/demos/alert-aggregator/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertTypeNonSDOImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/demos/alert-aggregator/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertTypeNonSDOImpl.java?view=diff&rev=550354&r1=550353&r2=550354
==============================================================================
--- incubator/tuscany/java/sca/demos/alert-aggregator/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertTypeNonSDOImpl.java (original)
+++ incubator/tuscany/java/sca/demos/alert-aggregator/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertTypeNonSDOImpl.java Sun Jun 24 22:31:14 2007
@@ -1,8 +1,20 @@
-/**
- * <copyright>
- * </copyright>
- *
- * $Id$
+/*
+ * 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.demos.aggregator;
Modified: incubator/tuscany/java/sca/demos/alert-aggregator/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsTypeNonSDOImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/demos/alert-aggregator/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsTypeNonSDOImpl.java?view=diff&rev=550354&r1=550353&r2=550354
==============================================================================
--- incubator/tuscany/java/sca/demos/alert-aggregator/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsTypeNonSDOImpl.java (original)
+++ incubator/tuscany/java/sca/demos/alert-aggregator/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsTypeNonSDOImpl.java Sun Jun 24 22:31:14 2007
@@ -1,8 +1,20 @@
-/**
- * <copyright>
- * </copyright>
- *
- * $Id$
+/*
+ * 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.demos.aggregator;
Modified: incubator/tuscany/java/sca/demos/alert-aggregator/src/main/java/org/apache/tuscany/sca/demos/aggregator/ConfigTypeNonSDOImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/demos/alert-aggregator/src/main/java/org/apache/tuscany/sca/demos/aggregator/ConfigTypeNonSDOImpl.java?view=diff&rev=550354&r1=550353&r2=550354
==============================================================================
--- incubator/tuscany/java/sca/demos/alert-aggregator/src/main/java/org/apache/tuscany/sca/demos/aggregator/ConfigTypeNonSDOImpl.java (original)
+++ incubator/tuscany/java/sca/demos/alert-aggregator/src/main/java/org/apache/tuscany/sca/demos/aggregator/ConfigTypeNonSDOImpl.java Sun Jun 24 22:31:14 2007
@@ -1,8 +1,20 @@
-/**
- * <copyright>
- * </copyright>
- *
- * $Id$
+/*
+ * 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.demos.aggregator;
Modified: incubator/tuscany/java/sca/demos/alert-aggregator/src/main/java/org/apache/tuscany/sca/demos/aggregator/SourceTypeNonSDOImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/demos/alert-aggregator/src/main/java/org/apache/tuscany/sca/demos/aggregator/SourceTypeNonSDOImpl.java?view=diff&rev=550354&r1=550353&r2=550354
==============================================================================
--- incubator/tuscany/java/sca/demos/alert-aggregator/src/main/java/org/apache/tuscany/sca/demos/aggregator/SourceTypeNonSDOImpl.java (original)
+++ incubator/tuscany/java/sca/demos/alert-aggregator/src/main/java/org/apache/tuscany/sca/demos/aggregator/SourceTypeNonSDOImpl.java Sun Jun 24 22:31:14 2007
@@ -1,8 +1,20 @@
-/**
- * <copyright>
- * </copyright>
- *
- * $Id$
+/*
+ * 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.demos.aggregator;
Modified: incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java?view=diff&rev=550354&r1=550353&r2=550354
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java Sun Jun 24 22:31:14 2007
@@ -47,6 +47,8 @@
import org.apache.tuscany.sca.assembly.Reference;
import org.apache.tuscany.sca.assembly.Service;
import org.apache.tuscany.sca.assembly.Wire;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.DeployedArtifact;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.contribution.service.ContributionReadException;
@@ -64,6 +66,9 @@
*/
public class CompositeProcessor extends BaseArtifactProcessor implements StAXArtifactProcessor<Composite> {
+ private ContributionFactory contributionFactory;
+ private DeployedArtifact deployedArtifact;
+
/**
* Construct a new composite processor
* @param assemblyFactory
@@ -72,8 +77,9 @@
*/
public CompositeProcessor(AssemblyFactory factory, PolicyFactory policyFactory,
InterfaceContractMapper interfaceContractMapper,
- StAXArtifactProcessor extensionProcessor) {
+ StAXArtifactProcessor extensionProcessor, ContributionFactory contributionFactory) {
super(factory, policyFactory, extensionProcessor);
+ this.contributionFactory = contributionFactory;
}
public Composite read(XMLStreamReader reader) throws ContributionReadException {
@@ -175,6 +181,10 @@
property = componentProperty;
componentProperty.setSource(getString(reader, SOURCE));
componentProperty.setFile(getString(reader, FILE));
+ if ( componentProperty.getFile() != null) {
+ deployedArtifact = contributionFactory.createDeployedArtifact();
+ deployedArtifact.setURI(componentProperty.getFile());
+ }
readPolicies(property, reader);
readProperty(componentProperty, reader);
component.getProperties().add(componentProperty);
@@ -436,6 +446,8 @@
ConstrainingType constrainingType = composite.getConstrainingType();
constrainingType = resolver.resolveModel(ConstrainingType.class, constrainingType);
composite.setConstrainingType(constrainingType);
+
+ Object obj = resolver.resolveModel(DeployedArtifact.class, deployedArtifact);
// Resolve includes in the composite
for (int i = 0, n = composite.getIncludes().size(); i < n; i++) {
Modified: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntimeBuilder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntimeBuilder.java?view=diff&rev=550354&r1=550353&r2=550354
==============================================================================
--- incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntimeBuilder.java (original)
+++ incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntimeBuilder.java Sun Jun 24 22:31:14 2007
@@ -155,7 +155,7 @@
XMLOutputFactory
.newInstance());
staxProcessors.addArtifactProcessor(new CompositeProcessor(assemblyFactory, policyFactory, mapper,
- staxProcessor));
+ staxProcessor, contributionFactory));
staxProcessors.addArtifactProcessor(new ComponentTypeProcessor(assemblyFactory, policyFactory, staxProcessor));
staxProcessors
.addArtifactProcessor(new ConstrainingTypeProcessor(assemblyFactory, policyFactory, staxProcessor));
Modified: incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/engines/TuscanyJRubyScriptEngine.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/engines/TuscanyJRubyScriptEngine.java?view=diff&rev=550354&r1=550353&r2=550354
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/engines/TuscanyJRubyScriptEngine.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/engines/TuscanyJRubyScriptEngine.java Sun Jun 24 22:31:14 2007
@@ -228,7 +228,7 @@
filename = "<unknown>";
}
return runtime.parse(script, filename, null, 0);
- } catch (Exception exp) {
+ } catch (Exception exp) {
throw new ScriptException(exp);
} finally {
if (oldGlobals != null) {
Added: incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/BindingType.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/BindingType.java?view=auto&rev=550354
==============================================================================
--- incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/BindingType.java (added)
+++ incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/BindingType.java Sun Jun 24 22:31:14 2007
@@ -0,0 +1,31 @@
+/*
+ * 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.policy;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+
+/**
+ * Represents a Binding Type and its support of various QoS policies
+ *
+ */
+public interface BindingType extends ExtensionType {
+}
Added: incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.java?view=auto&rev=550354
==============================================================================
--- incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.java (added)
+++ incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.java Sun Jun 24 22:31:14 2007
@@ -0,0 +1,59 @@
+/*
+ * 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.policy;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.policy.Intent;
+
+
+/**
+ * Represents the base ExtensionType for BindingType and ImplementationType
+ * and its support of various QoS policies
+ *
+ */
+public interface ExtensionType extends Visitable {
+ /**
+ * Returns the name of the extension type defined by this instance e.g. implementation.java, binding.ws
+ * @return the extension type QName
+ */
+ QName getTypeName();
+
+ /**
+ * Sets the name of the extension type
+ * @param the name of the extension type
+ */
+ void setTypeName(QName type);
+
+ /**
+ * Returns the list of names of policy intents that will always be provided by this Extension Type
+ * @ruturn list of Policy Intent names
+ */
+ List<QName> getAlwaysProvidedPolicyIntents();
+
+ /**
+ * Returns the list of names of policy intents that may be provided by this Extension Type thro
+ * appropriate configuration
+ * @ruturn list of Policy Intent names
+ */
+ List<QName> getMayProvidePolicyIntents();
+}
Added: incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java?view=auto&rev=550354
==============================================================================
--- incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java (added)
+++ incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java Sun Jun 24 22:31:14 2007
@@ -0,0 +1,29 @@
+/*
+ * 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.policy;
+
+
+
+/**
+ * Represents an Implementation Type and its support of various QoS policies
+ *
+ */
+public interface ImplementationType extends ExtensionType {
+}
Modified: incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java?view=diff&rev=550354&r1=550353&r2=550354
==============================================================================
--- incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java (original)
+++ incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java Sun Jun 24 22:31:14 2007
@@ -39,27 +39,26 @@
* @param providedIntent the intent realized by this intent map
*/
void setProvidedIntent(Intent providedIntent);
-
+
/**
- * Returns the default qualified intent map.
+ * Returns the list of qualifiers for this Intent Map
*
- * @return the default qualified intent map
+ * @return
*/
- IntentMap getDefaultQualifiedIntentMap();
-
+ List<IntentMapQualifier> getQualifiers();
+
/**
- * Sets the default qualified intent map.
- *
- * @param defaultQualifiedIntentMap the default qualified intent map
+ * Returns the default qualifier for this Intent Map
+ * @return
*/
- void setDefaultQualifiedIntentMap(IntentMap defaultQualifiedIntentMap);
-
+ IntentMapQualifier getDefaultQualifier();
+
/**
- * Returns the list of children qualified intent maps.
+ * sets the default qualifier for this Intent Map
*
- * @return
+ * @param qualifier
*/
- List<IntentMap> getQualifiedIntentMaps();
+ void setDefaultQualifier(IntentMapQualifier qualifier);
/**
* Returns the list of concrete policies, either WS-Policy policy
@@ -83,5 +82,19 @@
* @param unresolved whether the model element is unresolved
*/
void setUnresolved(boolean unresolved);
+
+ /**
+ * Returns the default qualified intent map.
+ *
+ * @return the default qualified intent map
+
+ IntentMap getDefaultQualifiedIntentMap();*/
+
+ /**
+ * Sets the default qualified intent map.
+ *
+ * @param defaultQualifiedIntentMap the default qualified intent map
+
+ void setDefaultQualifiedIntentMap(IntentMap defaultQualifiedIntentMap);*/
}
Added: incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentMapQualifier.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentMapQualifier.java?view=auto&rev=550354
==============================================================================
--- incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentMapQualifier.java (added)
+++ incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentMapQualifier.java Sun Jun 24 22:31:14 2007
@@ -0,0 +1,80 @@
+/*
+ * 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.policy;
+
+import java.util.List;
+
+/**
+ * Represents a qualifier for a policy intent map. See the Policy Framework specification for a
+ * description of this element.
+ */
+public interface IntentMapQualifier {
+
+ /**
+ * Returns the name of this qualifier
+ *
+ * @return name of the qualifier
+ */
+ String getName();
+
+ /**
+ * sets the name for this qualifier
+ *
+ * @param name name of the qualifier
+ */
+ void setName(String name);
+
+ /**
+ * Returns the intent map for this qualified intent
+ *
+ * @return the intent map for this qualified intent
+ */
+ IntentMap getQualifiedIntentMap();
+
+ /**
+ * sets the intent map for this qualified intent
+ *
+ * @param intentMap
+ */
+ void setQualifiedIntentMap(IntentMap intentMap);
+
+ /**
+ * Returns the list of concrete policies, either WS-Policy policy
+ * attachments, policy references, or policies expressed in another policy
+ * language.
+ *
+ * @return the list of concrete policies
+ */
+ List<Object> getPolicies();
+
+ /**
+ * Returns true if the model element is unresolved.
+ *
+ * @return true if the model element is unresolved.
+ */
+ boolean isUnresolved();
+
+ /**
+ * Sets whether the model element is unresolved.
+ *
+ * @param unresolved whether the model element is unresolved
+ */
+ void setUnresolved(boolean unresolved);
+
+}
Modified: incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java?view=diff&rev=550354&r1=550353&r2=550354
==============================================================================
--- incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java (original)
+++ incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java Sun Jun 24 22:31:14 2007
@@ -43,5 +43,12 @@
* @return a new intent map
*/
IntentMap createIntentMap();
+
+ /**
+ * Create a new intent map qualifier.
+ *
+ * @return a new intent map qualifier
+ */
+ IntentMapQualifier createIntentMapQualifier();
}
Modified: incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java?view=diff&rev=550354&r1=550353&r2=550354
==============================================================================
--- incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java (original)
+++ incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java Sun Jun 24 22:31:14 2007
@@ -64,15 +64,20 @@
* @return
*/
List<Intent> getProvidedIntents();
-
+
/**
- * Returns the list of SCA constructs that this policy set is meant to
- * configure.
+ * Returns the xpath expression used to determing the SCA Contructs to which this PolicySet applies
*
- * @return the list of SCA constructs that this policy set is meant to
- * configure
+ * @return xpath expression string
+ */
+ String getAppliesTo();
+
+ /**
+ * Sets the xpath expression used to determing the SCA Contructs to which this PolicySet applies
+ *
+ * @param xpathExp the xpath expression string
*/
- List<QName> getAppliesTo();
+ void setAppliesTo(String xpathExp);
/**
* Returns the list of concrete policies, either WS-Policy policy
@@ -97,4 +102,12 @@
*/
void setUnresolved(boolean unresolved);
+ /**
+ * Returns the list of SCA constructs that this policy set is meant to
+ * configure.
+ *
+ * @return the list of SCA constructs that this policy set is meant to
+ * configure
+
+ List<QName> getAppliesTo();*/
}
Added: incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/SCADefinitions.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/SCADefinitions.java?view=auto&rev=550354
==============================================================================
--- incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/SCADefinitions.java (added)
+++ incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/SCADefinitions.java Sun Jun 24 22:31:14 2007
@@ -0,0 +1,72 @@
+/*
+ * 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.policy;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+
+/**
+ * Represents SCA Definitions.
+ *
+ */
+public interface SCADefinitions /*extends Visitable*/ {
+ /**
+ * Returns the target namespace for this SCA Definition
+ * @return the target namespace
+ */
+ QName getTargetNamespace();
+
+ /**
+ * Sets the target names for this SCA Definition
+ *
+ * @param the target namespace for this SCA Definition
+ */
+ void setTargetNamespace(QName ns);
+
+ /**
+ * Returns a list of domain wide Policy Intents
+ *
+ * @return a list of domain wide Policy Intents
+ */
+ List<Intent> getPolicyIntents();
+
+ /**
+ * Returns a list of domain wide PolicySets
+ *
+ * @return a list of domain wide PolicySets
+ */
+ List<PolicySet> getPolicySets();
+
+ /**
+ * Returns a list of domain wide Binding Types
+ *
+ * @return a list of domain wide Binding Types
+ */
+ List<BindingType> getBindingTypes();
+
+
+ /**
+ * Returns a list of domain wide Implementation Types
+ *
+ * @return a list of domain wide Implementation Types
+ */
+ List<ImplementationType> getImplementationTypes();
+}
Added: incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java?view=auto&rev=550354
==============================================================================
--- incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java (added)
+++ incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java Sun Jun 24 22:31:14 2007
@@ -0,0 +1,29 @@
+/*
+ * 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.policy.impl;
+
+import org.apache.tuscany.sca.assembly.BindingType;
+
+/**
+ * Provides a concrete implemenation for BindingType
+ *
+ */
+public class BindingTypeImpl extends ExtensionTypeImpl implements BindingType{
+}
Added: incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java?view=auto&rev=550354
==============================================================================
--- incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java (added)
+++ incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java Sun Jun 24 22:31:14 2007
@@ -0,0 +1,59 @@
+/*
+ * 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.policy.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.ExtensionType;
+import org.apache.tuscany.sca.assembly.Visitor;
+import org.apache.tuscany.sca.policy.Intent;
+
+/**
+ * Provides a concrete implementation for ExtensionType
+ *
+ */
+public abstract class ExtensionTypeImpl implements ExtensionType {
+ private QName typeName = null;
+ private List<QName> alwaysProvidedPolicyIntents = new ArrayList<QName>();
+ private List<QName> mayProvidesPolicyIntents = new ArrayList<QName>();
+
+ public List<QName> getAlwaysProvidedPolicyIntents() {
+ return alwaysProvidedPolicyIntents;
+ }
+
+ public QName getTypeName() {
+ return typeName;
+ }
+
+ public void setTypeName(QName type) {
+ this.typeName = type;
+ }
+
+ public List<QName> getMayProvidePolicyIntents() {
+ return mayProvidesPolicyIntents;
+ }
+
+ public boolean accept(Visitor visitor) {
+ return false;
+ }
+
+}
Added: incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java?view=auto&rev=550354
==============================================================================
--- incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java (added)
+++ incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java Sun Jun 24 22:31:14 2007
@@ -0,0 +1,29 @@
+/*
+ * 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.policy.impl;
+
+import org.apache.tuscany.sca.assembly.BindingType;
+
+/**
+ * Provides a concrete implementation for ImplementationType
+ *
+ */
+public class ImplementationTypeImpl extends ExtensionTypeImpl implements BindingType{
+}
Modified: incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java?view=diff&rev=550354&r1=550353&r2=550354
==============================================================================
--- incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java (original)
+++ incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java Sun Jun 24 22:31:14 2007
@@ -23,6 +23,7 @@
import javax.xml.namespace.QName;
+import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.policy.Intent;
@@ -82,5 +83,20 @@
public void setUnresolved(boolean unresolved) {
this.unresolved = unresolved;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ } else if (obj instanceof Intent) {
+ if (getName() != null) {
+ return getName().equals(((Intent)obj).getName());
+ } else {
+ return ((Intent)obj).getName() == null;
+ }
+ } else {
+ return false;
+ }
}
}
Added: incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapQualifierImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapQualifierImpl.java?view=auto&rev=550354
==============================================================================
--- incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapQualifierImpl.java (added)
+++ incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapQualifierImpl.java Sun Jun 24 22:31:14 2007
@@ -0,0 +1,72 @@
+/*
+ * 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.policy.impl;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.policy.IntentMap;
+import org.apache.tuscany.sca.policy.IntentMapQualifier;
+
+/**
+ * @author administrator
+ *
+ */
+public class IntentMapQualifierImpl implements IntentMapQualifier {
+
+ private IntentMap qualifiedIntentMap = null;
+
+ public String getName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<Object> getPolicies() {
+ return policies;
+ }
+
+ public IntentMap getQualifiedIntentMap() {
+ return qualifiedIntentMap;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.tuscany.sca.policy.IntentMapQualifier#setName(java.lang.String)
+ */
+ public void setName(String name) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.tuscany.sca.policy.IntentMapQualifier#setQualifiedIntentMap(org.apache.tuscany.sca.policy.IntentMap)
+ */
+ public void setQualifiedIntentMap(IntentMap intentMap) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+
+}
Modified: incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java?view=diff&rev=550354&r1=550353&r2=550354
==============================================================================
--- incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java (original)
+++ incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java Sun Jun 24 22:31:14 2007
@@ -20,6 +20,7 @@
import org.apache.tuscany.sca.policy.Intent;
import org.apache.tuscany.sca.policy.IntentMap;
+import org.apache.tuscany.sca.policy.IntentMapQualifier;
import org.apache.tuscany.sca.policy.PolicyFactory;
import org.apache.tuscany.sca.policy.PolicySet;
@@ -40,6 +41,10 @@
public IntentMap createIntentMap() {
return new IntentMapImpl();
+ }
+
+ public IntentMapQualifier createIntentMapQualifier() {
+ return new IntentMapQualifierImpl();
}
}
Modified: incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java?view=diff&rev=550354&r1=550353&r2=550354
==============================================================================
--- incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java (original)
+++ incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java Sun Jun 24 22:31:14 2007
@@ -36,7 +36,8 @@
private QName name;
private List<Operation> operations = new ArrayList<Operation>();
- private List<QName> appliesTo;
+ //private List<QName> appliesTo;
+ private String appliesTo;
private List<Intent> providedIntents;
private List<PolicySet> referencedPolicySets;
private List<Object> policies;
@@ -57,9 +58,9 @@
return operations;
}
- public List<QName> getAppliesTo() {
+ /*public List<QName> getAppliesTo() {
return appliesTo;
- }
+ }*/
public List<Intent> getProvidedIntents() {
return providedIntents;
@@ -79,5 +80,13 @@
public void setUnresolved(boolean unresolved) {
this.unresolved = unresolved;
+ }
+
+ public String getAppliesTo() {
+ return appliesTo;
+ }
+
+ public void setAppliesTo(String xpathExp) {
+ this.appliesTo = xpathExp;
}
}
Added: incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/SCADefinitionsImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/SCADefinitionsImpl.java?view=auto&rev=550354
==============================================================================
--- incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/SCADefinitionsImpl.java (added)
+++ incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/SCADefinitionsImpl.java Sun Jun 24 22:31:14 2007
@@ -0,0 +1,73 @@
+/*
+ * 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.policy.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ImplementationType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.SCADefinitions;
+
+/**
+ * Provides a concrete implementation for SCADefinitions
+ *
+ */
+public class SCADefinitionsImpl implements SCADefinitions {
+ private QName targetNamespace = null;
+ private List<Intent> policyIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private List<BindingType> bindingTypes = new ArrayList<BindingType>();
+ private List<ImplementationType> implementationTypes = new ArrayList<ImplementationType>();
+
+
+ public List<BindingType> getBindingTypes() {
+ return bindingTypes;
+ }
+
+ public List<ImplementationType> getImplementationTypes() {
+ return implementationTypes;
+ }
+
+ public List<Intent> getPolicyIntents() {
+ return policyIntents;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public QName getTargetNamespace() {
+ return targetNamespace;
+ }
+
+ public void setTargetNamespace(QName ns) {
+ this.targetNamespace = ns;
+ }
+
+ /*public boolean accept(Visitor visitor) {
+ return false;
+ }*/
+
+}
Added: incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/service/DuplicateEntryException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/service/DuplicateEntryException.java?view=auto&rev=550354
==============================================================================
--- incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/service/DuplicateEntryException.java (added)
+++ incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/service/DuplicateEntryException.java Sun Jun 24 22:31:14 2007
@@ -0,0 +1,27 @@
+/**
+ *
+ * Copyright 2006 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.tuscany.sca.policy.service;
+
+/**
+ * Exception to be thrown if there is an attempt to add duplicate intent or policy set entries
+ *
+ */
+public class DuplicateEntryException extends Exception {
+
+ private static final long serialVersionUID = -7098673804761839486L;
+
+}
Added: incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/service/EntryNotFoundException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/service/EntryNotFoundException.java?view=auto&rev=550354
==============================================================================
--- incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/service/EntryNotFoundException.java (added)
+++ incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/service/EntryNotFoundException.java Sun Jun 24 22:31:14 2007
@@ -0,0 +1,25 @@
+/**
+ *
+ * Copyright 2006 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.tuscany.sca.policy.service;
+
+/**
+ * Exception to be thrown when an intent or policyset is not found
+ *
+ */
+public class EntryNotFoundException extends Exception {
+
+}
Added: incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/service/PolicyService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/service/PolicyService.java?view=auto&rev=550354
==============================================================================
--- incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/service/PolicyService.java (added)
+++ incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/service/PolicyService.java Sun Jun 24 22:31:14 2007
@@ -0,0 +1,36 @@
+/**
+ *
+ * Copyright 2006 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.tuscany.sca.policy.service;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * This is the interface for the Policy Infrastructure. It deals with the maintenance of intents and
+ * policy sets defined for a SCA Domain, validating the endpoints of a wire for
+ *
+ */
+public interface PolicyService {
+ void addIntent(Intent anIntent) throws DuplicateEntryException;
+ void addPolicySet(PolicySet aPolicySet) throws DuplicateEntryException;
+
+ void removeIntent(QName intentName) throws EntryNotFoundException;
+ void removePolicySet(QName policySetName) throws EntryNotFoundException;
+
+}
Added: incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/service/impl/DefaultPolicyServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/service/impl/DefaultPolicyServiceImpl.java?view=auto&rev=550354
==============================================================================
--- incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/service/impl/DefaultPolicyServiceImpl.java (added)
+++ incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/service/impl/DefaultPolicyServiceImpl.java Sun Jun 24 22:31:14 2007
@@ -0,0 +1,51 @@
+/**
+ *
+ * Copyright 2006 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.tuscany.sca.policy.service.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.service.DuplicateEntryException;
+import org.apache.tuscany.sca.policy.service.EntryNotFoundException;
+import org.apache.tuscany.sca.policy.service.PolicyService;
+
+/**
+ * Provides a Default implementation for the Policy Service
+ */
+public class DefaultPolicyServiceImpl implements PolicyService {
+ private Map<QName, Intent> intentsRegistry = new HashMap<QName, Intent>();
+ private Map<QName, PolicySet> policySetRegistry = new HashMap<QName, PolicySet>();
+
+ public void addIntent(Intent anIntent) throws DuplicateEntryException {
+ intentsRegistry.put(anIntent.getName(), anIntent);
+ }
+ public void addPolicySet(PolicySet aPolicySet) throws DuplicateEntryException {
+ policySetRegistry.put(aPolicySet.getName(), aPolicySet);
+
+ }
+ public void removeIntent(QName intentName) throws EntryNotFoundException {
+ intentsRegistry.remove(intentName);
+
+ }
+ public void removePolicySet(QName policySetName) throws EntryNotFoundException {
+ policySetRegistry.remove(policySetName);
+ }
+}
Added: incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java?view=auto&rev=550354
==============================================================================
--- incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java (added)
+++ incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java Sun Jun 24 22:31:14 2007
@@ -0,0 +1,51 @@
+/*
+ * 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.policy.xml;
+
+import javax.xml.namespace.QName;
+
+/**
+ * constants related to policy framework
+ *
+ */
+public interface PolicyConstants {
+ String SCA10_NS = "http://www.osoa.org/xmlns/sca/1.0";
+ String INTENT = "intent";
+ String INTENT_MAP = "intentMap";
+ String NAME = "name";
+ String TARGET_NAMESPACE = "targetNamespace";
+ String SCA_DEFINITIONS = "definitions";
+ String CONSTRAINS = "constrains";
+ String DESCRIPTION = "description";
+ String PROVIDES = "provides";
+ String APPLIES_TO = "appliesTo";
+ String QUALIFIER = "qualifier";
+
+ QName POLICY_INTENT_QNAME = new QName(SCA10_NS, INTENT);
+ QName POLICY_SET_QNAME = new QName(SCA10_NS, "policySet");
+ QName POLICY_INTENT_MAP_QNAME = new QName(SCA10_NS, INTENT_MAP);
+ QName SCA_DEFNS_QNAME = new QName(SCA10_NS, SCA_DEFINITIONS);
+ QName DESCRIPTION_QNAME = new QName(SCA10_NS, DESCRIPTION);
+ QName POLICY_INTENT_MAP_QUALIFIER_QNAME = new QName(SCA10_NS, QUALIFIER);
+
+
+
+
+
+}
Added: incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyIntentProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyIntentProcessor.java?view=auto&rev=550354
==============================================================================
--- incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyIntentProcessor.java (added)
+++ incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyIntentProcessor.java Sun Jun 24 22:31:14 2007
@@ -0,0 +1,197 @@
+/*
+ * 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.policy.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import java.util.List;
+import java.util.StringTokenizer;
+
+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.xml.Constants;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+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.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+
+public class PolicyIntentProcessor implements StAXArtifactProcessor<Intent>, PolicyConstants {
+
+ private PolicyFactory policyFactory;
+
+ public PolicyIntentProcessor(PolicyFactory policyFactory) {
+ this.policyFactory = policyFactory;
+ }
+
+ public Intent read(XMLStreamReader reader) throws ContributionReadException {
+ try {
+ // Read an <sca:intent>
+ Intent policyIntent = policyFactory.createIntent();
+ policyIntent.setName(new QName(reader.getAttributeValue(null, Constants.NAME)));
+
+ readRequiredIntents(policyIntent, reader);
+ readConstrainedArtifacts(policyIntent, reader);
+
+ int event = reader.getEventType();
+ QName name = null;
+ while (reader.hasNext()) {
+ event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT : {
+ name = reader.getName();
+ if (DESCRIPTION.equals(name)) {
+ policyIntent.setDescription(reader.getElementText());
+ }
+ break;
+ }
+ }
+ if (event == END_ELEMENT && POLICY_INTENT_QNAME.equals(reader.getName())) {
+ break;
+ }
+
+ //Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+ return policyIntent;
+
+ } catch (XMLStreamException e) {
+ throw new ContributionReadException(e);
+ }
+ }
+
+ public void write(Intent policyIntent, XMLStreamWriter writer) throws ContributionWriteException {
+ try {
+ // Write an <sca:intent>
+ writer.writeStartElement(Constants.SCA10_NS, INTENT);
+ if (policyIntent.getRequiredIntents() != null &&
+ policyIntent.getRequiredIntents().size() > 0) {
+ StringBuffer sb = new StringBuffer();
+ for (Intent requiredIntents : policyIntent.getRequiredIntents()) {
+ sb.append(requiredIntents.getName());
+ sb.append(" ");
+ }
+ writer.writeAttribute(Constants.REQUIRES, sb.toString());
+ }
+
+ if (policyIntent.getConstrains() != null &&
+ policyIntent.getConstrains().size() > 0) {
+ StringBuffer sb = new StringBuffer();
+ for (QName contrainedArtifact : policyIntent.getConstrains()) {
+ sb.append(contrainedArtifact.toString());
+ sb.append(" ");
+ }
+ writer.writeAttribute(CONSTRAINS, sb.toString());
+ } else {
+ throw new ContributionWriteException("Contrains attribute missing from " +
+ "Policy Intent Definition" + policyIntent.getName());
+ }
+
+ if ( policyIntent.getDescription() != null && policyIntent.getDescription().length() > 0) {
+ writer.writeStartElement(Constants.SCA10_NS, DESCRIPTION);
+ writer.writeCData(policyIntent.getDescription());
+ writer.writeEndElement();
+ }
+
+ writer.writeEndElement();
+
+ } catch (XMLStreamException e) {
+ throw new ContributionWriteException(e);
+ }
+ }
+
+ private Intent resolveRequiredIntents(Intent policyIntent, ModelResolver resolver) throws ContributionResolveException {
+ boolean isUnresolved = false;
+ //FIXME: Need to check for cyclic references first i.e an A requiring B and then B requiring A...
+ if (policyIntent != null && policyIntent.isUnresolved()) {
+ //resolve all required intents
+ for (Intent requiredIntent : policyIntent.getRequiredIntents()) {
+ if ( requiredIntent.isUnresolved() ) {
+ requiredIntent = resolver.resolveModel(Intent.class, requiredIntent);
+ if (!requiredIntent.isUnresolved()) {
+ isUnresolved = true;
+ }
+ }
+ }
+ }
+ policyIntent.setUnresolved(isUnresolved);
+
+ return policyIntent;
+ }
+
+ public void resolve(Intent policyIntent, ModelResolver resolver) throws ContributionResolveException {
+ resolveRequiredIntents(policyIntent, resolver);
+ }
+
+ public QName getArtifactType() {
+ return POLICY_INTENT_QNAME;
+ }
+
+ public Class<Intent> getModelType() {
+ return Intent.class;
+ }
+
+ protected void readConstrainedArtifacts(Intent policyIntent, XMLStreamReader reader) {
+ String value = reader.getAttributeValue(null, CONSTRAINS);
+ if (value != null) {
+ List<QName> constrainedArtifacts = policyIntent.getConstrains();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ constrainedArtifacts.add(qname);
+ }
+ }
+ }
+
+ protected void readRequiredIntents(Intent policyIntent, XMLStreamReader reader) {
+ String value = reader.getAttributeValue(null, Constants.REQUIRES);
+ if (value != null) {
+ List<Intent> requiredIntents = policyIntent.getRequiredIntents();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ Intent intent = policyFactory.createIntent();
+ intent.setName(qname);
+ requiredIntents.add(intent);
+ }
+ }
+ }
+
+ protected QName getQNameValue(XMLStreamReader reader, String value) {
+ if (value != null) {
+ int index = value.indexOf(':');
+ String prefix = index == -1 ? "" : value.substring(0, index);
+ String localName = index == -1 ? value : value.substring(index + 1);
+ String ns = reader.getNamespaceContext().getNamespaceURI(prefix);
+ if (ns == null) {
+ ns = "";
+ }
+ return new QName(ns, localName, prefix);
+ } else {
+ return null;
+ }
+ }
+}
Added: incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java?view=auto&rev=550354
==============================================================================
--- incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java (added)
+++ incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java Sun Jun 24 22:31:14 2007
@@ -0,0 +1,228 @@
+/*
+ * 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.policy.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import java.util.List;
+import java.util.StringTokenizer;
+
+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.xml.Constants;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+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.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentMap;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+public class PolicySetProcessor implements StAXArtifactProcessor<Intent>, PolicyConstants {
+
+ private PolicyFactory policyFactory;
+
+ public PolicySetProcessor(PolicyFactory policyFactory) {
+ this.policyFactory = policyFactory;
+ }
+
+ protected IntentMap readIntentMap(XMLStreamReader reader) {
+ //read sca:intentMap
+ IntentMap intentMap = policyFactory.createIntentMap();
+ Intent providedIntent = policyFactory.createIntent();
+ providedIntent.setName(new QName(reader.getAttributeValue(null, PROVIDES)));
+ intentMap.setProvidedIntent(providedIntent);
+ QName name = null;
+
+ while (reader.hasNext()) {
+ event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT : {
+ name = reader.getName();
+ if (POLICY_INTENT_MAP_QNAME.equals(name)) {
+
+
+
+ }
+ do {
+ switch (reader.getEventType()) {
+ case START_ELEMENT : {
+ name = reader.getName();
+ if (POLICY_INTENT_MAP_QNAME.equals(reader.getName()) ) {
+
+
+ break;
+ }
+ }
+ name = reader.getName();
+
+ } while (reader.hasNext());
+
+
+
+ intentMap.set
+
+
+ }
+
+ public PolicySet read(XMLStreamReader reader) throws ContributionReadException {
+ try {
+ // Read an <sca:policySet>
+ PolicySet policySet = policyFactory.createPolicySet();
+ policySet.setName(new QName(reader.getAttributeValue(null, Constants.NAME)));
+
+ readProvidedIntents(policySet, reader);
+ policySet.setAppliesTo(reader.getAttributeValue(null, APPLIES_TO));
+
+ int event = reader.getEventType();
+ QName name = null;
+ while (reader.hasNext()) {
+ event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT : {
+ name = reader.getName();
+ if (POLICY_INTENT_MAP_QNAME.equals(name)) {
+ readIntentMap(reader);
+ }
+ break;
+ }
+ }
+
+ if (event == END_ELEMENT && POLICY_SET_QNAME.equals(reader.getName())) {
+ break;
+ }
+
+ //Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+ return policySet;
+
+ } catch (XMLStreamException e) {
+ throw new ContributionReadException(e);
+ }
+ }
+
+ public void write(Intent policyIntent, XMLStreamWriter writer) throws ContributionWriteException {
+ try {
+ // Write an <sca:intent>
+ writer.writeStartElement(Constants.SCA10_NS, INTENT);
+ if (policyIntent.getRequiredIntents() != null &&
+ policyIntent.getRequiredIntents().size() > 0) {
+ StringBuffer sb = new StringBuffer();
+ for (Intent requiredIntents : policyIntent.getRequiredIntents()) {
+ sb.append(requiredIntents.getName());
+ sb.append(" ");
+ }
+ writer.writeAttribute(Constants.REQUIRES, sb.toString());
+ }
+
+ if (policyIntent.getConstrains() != null &&
+ policyIntent.getConstrains().size() > 0) {
+ StringBuffer sb = new StringBuffer();
+ for (QName contrainedArtifact : policyIntent.getConstrains()) {
+ sb.append(contrainedArtifact.toString());
+ sb.append(" ");
+ }
+ writer.writeAttribute(CONSTRAINS, sb.toString());
+ } else {
+ throw new ContributionWriteException("Contrains attribute missing from " +
+ "Policy Intent Definition" + policyIntent.getName());
+ }
+
+ if ( policyIntent.getDescription() != null && policyIntent.getDescription().length() > 0) {
+ writer.writeStartElement(Constants.SCA10_NS, DESCRIPTION);
+ writer.writeCData(policyIntent.getDescription());
+ writer.writeEndElement();
+ }
+
+ writer.writeEndElement();
+
+ } catch (XMLStreamException e) {
+ throw new ContributionWriteException(e);
+ }
+ }
+
+ private Intent resolveRequiredIntents(Intent policyIntent, ModelResolver resolver) throws ContributionResolveException {
+ boolean isUnresolved = false;
+ //FIXME: Need to check for cyclic references first i.e an A requiring B and then B requiring A...
+ if (policyIntent != null && policyIntent.isUnresolved()) {
+ //resolve all required intents
+ for (Intent requiredIntent : policyIntent.getRequiredIntents()) {
+ if ( requiredIntent.isUnresolved() ) {
+ requiredIntent = resolver.resolveModel(Intent.class, requiredIntent);
+ if (!requiredIntent.isUnresolved()) {
+ isUnresolved = true;
+ }
+ }
+ }
+ }
+ policyIntent.setUnresolved(isUnresolved);
+
+ return policyIntent;
+ }
+
+ public void resolve(Intent policyIntent, ModelResolver resolver) throws ContributionResolveException {
+ resolveRequiredIntents(policyIntent, resolver);
+ }
+
+ public QName getArtifactType() {
+ return POLICY_INTENT_QNAME;
+ }
+
+ public Class<Intent> getModelType() {
+ return Intent.class;
+ }
+
+ protected void readProvidedIntents(PolicySet policySet, XMLStreamReader reader) {
+ String value = reader.getAttributeValue(null, PROVIDES);
+ if (value != null) {
+ List<Intent> requiredIntents = policySet.getProvidedIntents();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ Intent intent = policyFactory.createIntent();
+ intent.setName(qname);
+ requiredIntents.add(intent);
+ }
+ }
+ }
+
+ protected QName getQNameValue(XMLStreamReader reader, String value) {
+ if (value != null) {
+ int index = value.indexOf(':');
+ String prefix = index == -1 ? "" : value.substring(0, index);
+ String localName = index == -1 ? value : value.substring(index + 1);
+ String ns = reader.getNamespaceContext().getNamespaceURI(prefix);
+ if (ns == null) {
+ ns = "";
+ }
+ return new QName(ns, localName, prefix);
+ } else {
+ return null;
+ }
+ }
+}
Added: incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/xml/SCADefinitionsDocumentProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/xml/SCADefinitionsDocumentProcessor.java?view=auto&rev=550354
==============================================================================
--- incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/xml/SCADefinitionsDocumentProcessor.java (added)
+++ incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/xml/SCADefinitionsDocumentProcessor.java Sun Jun 24 22:31:14 2007
@@ -0,0 +1,99 @@
+/*
+ * 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.policy.xml;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+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.policy.SCADefinitions;
+
+/**
+ * A SCA Definitions Document processor.
+ *
+ */
+public class SCADefinitionsDocumentProcessor implements URLArtifactProcessor<SCADefinitions> {
+ protected StAXArtifactProcessor<Object> extensionProcessor;
+
+ private static final DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
+ static {
+ domFactory.setNamespaceAware(true);
+ }
+ private XMLInputFactory inputFactory;
+
+ /**
+ * Construct a new SCADefinitions processor
+ * @param assemblyFactory
+ * @param policyFactory
+ * @param staxProcessor
+ */
+ public SCADefinitionsDocumentProcessor(StAXArtifactProcessor staxProcessor, XMLInputFactory inputFactory) {
+ this.extensionProcessor = (StAXArtifactProcessor<Object>)extensionProcessor;
+ this.inputFactory = inputFactory;
+ }
+
+ public SCADefinitions read(URL contributionURL, URI uri, URL url) throws ContributionReadException {
+ InputStream urlStream = null;
+ try {
+ urlStream = url.openStream();
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(urlStream);
+ reader.nextTag();
+ SCADefinitions scaDefns = (SCADefinitions)extensionProcessor.read(reader);
+ return scaDefns;
+
+ } catch (XMLStreamException e) {
+ throw new ContributionReadException(e);
+ } catch (IOException e) {
+ throw new ContributionReadException(e);
+ } finally {
+ try {
+ if (urlStream != null) {
+ urlStream.close();
+ urlStream = null;
+ }
+ } catch (IOException ioe) {
+ //ignore
+ }
+ }
+ }
+
+ public void resolve(SCADefinitions composite, ModelResolver resolver) throws ContributionResolveException {
+ extensionProcessor.resolve(composite, resolver);
+ }
+
+ public String getArtifactType() {
+ return "definitions.composite";
+ }
+
+ public Class<SCADefinitions> getModelType() {
+ return SCADefinitions.class;
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org