You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2009/10/13 02:21:22 UTC
svn commit: r824551 - in /tuscany/java/sca/modules/policy-logging: META-INF/
src/main/java/org/apache/tuscany/sca/policy/logging/jdk/
src/main/resources/META-INF/services/
Author: rfeng
Date: Tue Oct 13 00:21:22 2009
New Revision: 824551
URL: http://svn.apache.org/viewvc?rev=824551&view=rev
Log:
Add a policy builder for demo purpose
Added:
tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyBuilder.java (with props)
tuscany/java/sca/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.PolicyBuilder
Modified:
tuscany/java/sca/modules/policy-logging/META-INF/MANIFEST.MF
tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicy.java
Modified: tuscany/java/sca/modules/policy-logging/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/policy-logging/META-INF/MANIFEST.MF?rev=824551&r1=824550&r2=824551&view=diff
==============================================================================
--- tuscany/java/sca/modules/policy-logging/META-INF/MANIFEST.MF (original)
+++ tuscany/java/sca/modules/policy-logging/META-INF/MANIFEST.MF Tue Oct 13 00:21:22 2009
@@ -13,6 +13,7 @@
Import-Package: javax.xml.namespace,
javax.xml.stream,
org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.builder;version="2.0.0",
org.apache.tuscany.sca.contribution.processor;version="2.0.0",
org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
org.apache.tuscany.sca.core;version="2.0.0",
Modified: tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicy.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicy.java?rev=824551&r1=824550&r2=824551&view=diff
==============================================================================
--- tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicy.java (original)
+++ tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicy.java Tue Oct 13 00:21:22 2009
@@ -33,7 +33,7 @@
public class JDKLoggingPolicy {
static final String SCA11_NS = Base.SCA11_NS;
static final String SCA11_TUSCANY_NS = Base.SCA11_TUSCANY_NS;
- private static final QName JDK_LOGGING_POLICY_QNAME = new QName(SCA11_TUSCANY_NS, "jdkLogger");
+ static final QName JDK_LOGGING_POLICY_QNAME = new QName(SCA11_TUSCANY_NS, "jdkLogger");
private String loggerName;
private String resourceBundleName;
@@ -82,4 +82,16 @@
public void setUnresolved(boolean unresolved) {
}
+
+ @Override
+ public String toString() {
+ return "JDKLoggingPolicy [logLevel=" + logLevel
+ + ", loggerName="
+ + loggerName
+ + ", resourceBundleName="
+ + resourceBundleName
+ + ", useParentHandlers="
+ + useParentHandlers
+ + "]";
+ }
}
Added: tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyBuilder.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyBuilder.java?rev=824551&view=auto
==============================================================================
--- tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyBuilder.java (added)
+++ tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyBuilder.java Tue Oct 13 00:21:22 2009
@@ -0,0 +1,74 @@
+/*
+ * 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.logging.jdk;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.builder.PolicyBuilder;
+import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.policy.PolicyExpression;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ *
+ */
+public class JDKLoggingPolicyBuilder implements PolicyBuilder<JDKLoggingPolicy> {
+
+ public void build(Endpoint endpoint, Definitions definitions, Monitor monitor) {
+ List<JDKLoggingPolicy> polices = getPolicies(endpoint);
+ System.out.println(endpoint + ": " + polices);
+ }
+
+ public void build(EndpointReference endpointReference, Definitions definitions, Monitor monitor) {
+ List<JDKLoggingPolicy> polices = getPolicies(endpointReference);
+ System.out.println(endpointReference + ": " + polices);
+ }
+
+ public void build(Component component, Implementation implementation, Definitions definitions, Monitor monitor) {
+ List<JDKLoggingPolicy> polices = getPolicies(implementation);
+ System.out.println(implementation + ": " + polices);
+ }
+
+ public QName getPolicyType() {
+ return JDKLoggingPolicy.JDK_LOGGING_POLICY_QNAME;
+ }
+
+ private List<JDKLoggingPolicy> getPolicies(PolicySubject subject) {
+ List<JDKLoggingPolicy> polices = new ArrayList<JDKLoggingPolicy>();
+ for (PolicySet ps : subject.getPolicySets()) {
+ for (PolicyExpression exp : ps.getPolicies()) {
+ if (getPolicyType().equals(exp.getName())) {
+ polices.add((JDKLoggingPolicy)exp.getPolicy());
+ }
+ }
+ }
+ return polices;
+ }
+
+}
Propchange: tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/java/sca/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyBuilder.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: tuscany/java/sca/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.PolicyBuilder
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.PolicyBuilder?rev=824551&view=auto
==============================================================================
--- tuscany/java/sca/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.PolicyBuilder (added)
+++ tuscany/java/sca/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.PolicyBuilder Tue Oct 13 00:21:22 2009
@@ -0,0 +1,17 @@
+# 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.
+org.apache.tuscany.sca.policy.logging.jdk.JDKLoggingPolicyBuilder;qname=http://tuscany.apache.org/xmlns/sca/1.1#jdkLogger
\ No newline at end of file