diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2012-02-16 15:40:58 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2012-02-16 15:40:58 +0000 |
commit | aa4746677ae3be453d74205fd37571c21aa88637 (patch) | |
tree | 7e713405c13ac6bb12a30d330cfa4e171bb334c1 /sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src | |
parent | 2f187c12e2ceceb61ca2745463fcd7fbbb438b72 (diff) |
Rename beta3 tag to final name
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1245036 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src')
16 files changed, 0 insertions, 967 deletions
diff --git a/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/Logging.java b/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/Logging.java deleted file mode 100644 index 4bed9520ab..0000000000 --- a/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/Logging.java +++ /dev/null @@ -1,46 +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.policy.logging; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.PARAMETER; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import org.apache.tuscany.sca.assembly.Base; -import org.oasisopen.sca.annotation.Intent; -import org.oasisopen.sca.annotation.Qualifier; - -@Inherited -@Target({TYPE, FIELD, METHOD, PARAMETER}) -@Retention(RUNTIME) -@Intent(Logging.LOGGING) - -public @interface Logging { - String LOGGING = "{"+Base.SCA11_TUSCANY_NS + "}logging"; - - @Qualifier - String[] value() default ""; -} diff --git a/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingImplementationPolicyProvider.java b/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingImplementationPolicyProvider.java deleted file mode 100644 index 2963d8ce53..0000000000 --- a/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingImplementationPolicyProvider.java +++ /dev/null @@ -1,48 +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.policy.logging.jdk; - -import java.util.List; - -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.Phase; -import org.apache.tuscany.sca.invocation.PhasedInterceptor; -import org.apache.tuscany.sca.provider.BasePolicyProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; - -/** - * @version $Rev$ $Date$ - */ -public class JDKLoggingImplementationPolicyProvider extends BasePolicyProvider<JDKLoggingPolicy> { - - public JDKLoggingImplementationPolicyProvider(RuntimeComponent component) { - super(JDKLoggingPolicy.class, component.getImplementation()); - } - - /** - * @see org.apache.tuscany.sca.provider.PolicyProvider#createInterceptor(org.apache.tuscany.sca.interfacedef.Operation) - */ - public PhasedInterceptor createInterceptor(Operation operation) { - List<JDKLoggingPolicy> policies = findPolicies(); - return policies.isEmpty() ? null : new JDKLoggingPolicyInterceptor(subject, getContext(), operation, - policies, Phase.IMPLEMENTATION_POLICY); - } - -} diff --git a/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicy.java b/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicy.java deleted file mode 100644 index 6e1bad67c1..0000000000 --- a/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicy.java +++ /dev/null @@ -1,97 +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.policy.logging.jdk; - -import java.util.logging.Level; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.assembly.Base; - -/** - * Implementation for policies that could be injected as parameter - * into the axis2config. - * - * @version $Rev$ $Date$ - */ -public class JDKLoggingPolicy { - static final String SCA11_NS = Base.SCA11_NS; - static final String SCA11_TUSCANY_NS = Base.SCA11_TUSCANY_NS; - static final QName JDK_LOGGING_POLICY_QNAME = new QName(SCA11_TUSCANY_NS, "jdkLogger"); - - private String loggerName; - private String resourceBundleName; - private Level logLevel; - private boolean useParentHandlers = false; - - public String getLoggerName() { - return loggerName; - } - - public void setLoggerName(String loggerName) { - this.loggerName = loggerName; - } - - public Level getLogLevel() { - return logLevel; - } - - public void setLogLevel(Level logLevel) { - this.logLevel = logLevel; - } - - public String getResourceBundleName() { - return resourceBundleName; - } - - public void setResourceBundleName(String resourceBundleName) { - this.resourceBundleName = resourceBundleName; - } - - public boolean isUseParentHandlers() { - return useParentHandlers; - } - - public void setUseParentHandlers(boolean useParentHandlers) { - this.useParentHandlers = useParentHandlers; - } - - public QName getSchemaName() { - return JDK_LOGGING_POLICY_QNAME; - } - - public boolean isUnresolved() { - return false; - } - - public void setUnresolved(boolean unresolved) { - } - - @Override - public String toString() { - return "JDKLoggingPolicy [logLevel=" + logLevel - + ", loggerName=" - + loggerName - + ", resourceBundleName=" - + resourceBundleName - + ", useParentHandlers=" - + useParentHandlers - + "]"; - } -} diff --git a/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyBuilder.java b/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyBuilder.java deleted file mode 100644 index 8a71203b70..0000000000 --- a/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyBuilder.java +++ /dev/null @@ -1,84 +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.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.BuilderContext; -import org.apache.tuscany.sca.assembly.builder.PolicyBuilder; -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 boolean build(Endpoint endpoint, BuilderContext context) { - List<JDKLoggingPolicy> polices = getPolicies(endpoint); - System.out.println(endpoint + ": " + polices); - return true; - } - - public boolean build(EndpointReference endpointReference, BuilderContext context) { - List<JDKLoggingPolicy> polices = getPolicies(endpointReference); - System.out.println(endpointReference + ": " + polices); - return true; - } - - public boolean build(Component component, Implementation implementation, BuilderContext context) { - List<JDKLoggingPolicy> polices = getPolicies(implementation); - System.out.println(implementation + ": " + polices); - return true; - } - - public QName getPolicyType() { - return JDKLoggingPolicy.JDK_LOGGING_POLICY_QNAME; - } - - public List<QName> getSupportedBindings() { - return null; - } - - 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; - } - - public boolean build(EndpointReference endpointReference, Endpoint endpoint, BuilderContext context) { - return true; - } - -} diff --git a/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyInterceptor.java b/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyInterceptor.java deleted file mode 100644 index b6c83a804a..0000000000 --- a/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyInterceptor.java +++ /dev/null @@ -1,171 +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.policy.logging.jdk; - -import java.util.List; -import java.util.logging.ConsoleHandler; -import java.util.logging.Handler; -import java.util.logging.Level; -import java.util.logging.Logger; - -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.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.invocation.PhasedInterceptor; -import org.apache.tuscany.sca.policy.PolicySubject; - -/** - * Policy handler to handle PolicySet related to Logging with the QName - * {http://tuscany.apache.org/xmlns/sca/1.1/impl/java}LoggingPolicy - * - * @version $Rev$ $Date$ - */ -public class JDKLoggingPolicyInterceptor implements PhasedInterceptor { - public static final String loggingPolicy = "JDKLoggingPolicy"; - public static final QName policySetQName = new QName(JDKLoggingPolicy.SCA11_TUSCANY_NS, loggingPolicy); - private Logger logger = null; - - private Invoker next; - private Operation operation; - private List<JDKLoggingPolicy> policies; - private PolicySubject subject; - private String context; - private String phase; - - public JDKLoggingPolicyInterceptor(PolicySubject subject, - String context, - Operation operation, - List<JDKLoggingPolicy> policies, - String phase) { - super(); - this.operation = operation; - this.policies = policies; - this.subject = subject; - this.phase = phase; - this.context = getContext(); - init(); - } - - private String getContext() { - if (subject instanceof Endpoint) { - Endpoint endpoint = (Endpoint)subject; - return endpoint.getURI(); - } else if (subject instanceof EndpointReference) { - EndpointReference endpointReference = (EndpointReference)subject; - return endpointReference.getURI(); - } else if (subject instanceof Component) { - Component component = (Component)subject; - return component.getURI(); - } - return null; - } - - private void init() { - JDKLoggingPolicy policy = policies.get(0); - logger = Logger.getLogger(policy.getLoggerName()); - logger.setLevel(policy.getLogLevel()); - logger.setUseParentHandlers(policy.isUseParentHandlers()); - - boolean found = false; - for (Handler handler : logger.getHandlers()) { - if (handler instanceof ConsoleHandler) { - found = true; - break; - } - } - - if (!found) { - ConsoleHandler consoleHandler = new ConsoleHandler(); - consoleHandler.setLevel(Level.ALL); - logger.addHandler(consoleHandler); - } - - if (logger.isLoggable(Level.FINE)) { - logger.logp(Level.FINE, context, "", "Intents: {0}", subject.getRequiredIntents()); - logger.logp(Level.FINE, context, "", "PolicySets: {0}", subject.getPolicySets()); - } - } - - public Message invoke(Message msg) { - if (logger == null) { - return getNext().invoke(msg); - } - logger.logp(Level.INFO, context, "", "Invoking operation - " + operation.getName()); - Object msgBody = msg.getBody(); - if (msgBody instanceof Object[]) { - - if (logger.isLoggable(Level.FINE)) { - StringBuffer sb = new StringBuffer(); - if (msgBody == null) { - sb.append(""); - } else { - Object[] args = (Object[])msgBody; - for (int i = 0; i < args.length; i++) { - sb.append(args[i]); - if (i != args.length - 1) { - sb.append(", "); - } - } - } - - Object[] logParams = new Object[] {operation.getName(), sb.toString()}; - logger.logp(Level.FINE, context, "", "Invoking operation {0} with arguments {1}", logParams); - } - } - - Message responseMsg = null; - try { - responseMsg = getNext().invoke(msg); - return responseMsg; - } catch (RuntimeException e) { - logger.logp(Level.SEVERE, context, "", "Exception thrown from operation - " + operation.getName(), e); - throw e; - } finally { - if (responseMsg != null) { - logger.logp(Level.INFO, context, "", "Returned from operation - " + operation.getName()); - if (logger.isLoggable(Level.FINE)) { - Object[] logParams = new Object[] {operation.getName(), responseMsg.getBody()}; - logger.logp(Level.FINE, - context, - "", - "Returning from operation {0} with return value {1}", - logParams); - } - } - } - } - - public Invoker getNext() { - return next; - } - - public void setNext(Invoker next) { - this.next = next; - } - - public String getPhase() { - return phase; - } - -} diff --git a/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProcessor.java b/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProcessor.java deleted file mode 100644 index a79aeb0e28..0000000000 --- a/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProcessor.java +++ /dev/null @@ -1,135 +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.policy.logging.jdk; - -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; -import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; - -import java.util.logging.Level; - -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.contribution.processor.ContributionReadException; -import org.apache.tuscany.sca.contribution.processor.ContributionResolveException; -import org.apache.tuscany.sca.contribution.processor.ContributionWriteException; -import org.apache.tuscany.sca.contribution.processor.ProcessorContext; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; - -/** - * - * @version $Rev$ $Date$ - */ -public class JDKLoggingPolicyProcessor implements StAXArtifactProcessor<JDKLoggingPolicy> { - private static final QName JDK_LOGGING_POLICY_QNAME = new QName(JDKLoggingPolicy.SCA11_TUSCANY_NS, "jdkLogger"); - private static final String LOG_LEVEL = "logLevel"; - private static final String RESOURCE_BUNDLE = "resourceBundle"; - private static final String USE_PARENT_HANDLERS = "useParentHandlers"; - - public QName getArtifactType() { - return JDK_LOGGING_POLICY_QNAME; - } - - public JDKLoggingPolicyProcessor(FactoryExtensionPoint modelFactories) { - } - - - public JDKLoggingPolicy read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException { - JDKLoggingPolicy policy = new JDKLoggingPolicy(); - int event = reader.getEventType(); - QName name = null; - - - while (reader.hasNext()) { - event = reader.getEventType(); - switch (event) { - case START_ELEMENT : { - name = reader.getName(); - if ( name.equals(JDK_LOGGING_POLICY_QNAME) ) { - String loggerName = reader.getAttributeValue(null, "name"); - policy.setLoggerName(loggerName); - } else if ( LOG_LEVEL.equals(name.getLocalPart()) ) { - policy.setLogLevel(Level.parse(reader.getElementText())); - } else if ( RESOURCE_BUNDLE.equals(name.getLocalPart()) ) { - policy.setResourceBundleName(reader.getElementText()); - } else if ( USE_PARENT_HANDLERS.equals(name.getLocalPart()) ) { - policy.setUseParentHandlers(Boolean.parseBoolean(reader.getElementText())); - } - break; - } - } - - if ( event == END_ELEMENT ) { - if ( JDK_LOGGING_POLICY_QNAME.equals(reader.getName()) ) { - break; - } - } - - //Read the next element - if (reader.hasNext()) { - reader.next(); - } - } - - return policy; - } - - public void write(JDKLoggingPolicy policy, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, - XMLStreamException { - String prefix = "tuscany"; - writer.writeStartElement(prefix, - JDK_LOGGING_POLICY_QNAME.getLocalPart(), - JDK_LOGGING_POLICY_QNAME.getNamespaceURI()); - writer.writeNamespace("tuscany", JDKLoggingPolicy.SCA11_TUSCANY_NS); - - if (policy.getLoggerName() != null) { - writer.writeAttribute("name", policy.getLoggerName()); - } - if ( policy.getLogLevel() != null ) { - writer.writeStartElement(prefix, - LOG_LEVEL, - JDK_LOGGING_POLICY_QNAME.getNamespaceURI()); - writer.writeCharacters(policy.getLogLevel().getLocalizedName()); - writer.writeEndElement(); - } - - if ( policy.getResourceBundleName() != null ) { - writer.writeStartElement(prefix, - RESOURCE_BUNDLE, - JDK_LOGGING_POLICY_QNAME.getNamespaceURI()); - writer.writeCharacters(policy.getResourceBundleName()); - writer.writeEndElement(); - } - - writer.writeEndElement(); - } - - public Class<JDKLoggingPolicy> getModelType() { - return JDKLoggingPolicy.class; - } - - public void resolve(JDKLoggingPolicy arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException { - - } - -} diff --git a/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProviderFactory.java b/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProviderFactory.java deleted file mode 100644 index 62bf06475b..0000000000 --- a/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProviderFactory.java +++ /dev/null @@ -1,68 +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.policy.logging.jdk; - -import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.assembly.EndpointReference; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.provider.PolicyProvider; -import org.apache.tuscany.sca.provider.PolicyProviderFactory; -import org.apache.tuscany.sca.runtime.RuntimeComponent; - -/** - * @version $Rev$ $Date$ - */ -public class JDKLoggingPolicyProviderFactory implements PolicyProviderFactory<JDKLoggingPolicy> { - private ExtensionPointRegistry registry; - - public JDKLoggingPolicyProviderFactory(ExtensionPointRegistry registry) { - super(); - this.registry = registry; - } - - /** - * @see org.apache.tuscany.sca.provider.PolicyProviderFactory#createImplementationPolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.assembly.Implementation) - */ - public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component) { - return new JDKLoggingImplementationPolicyProvider(component); - } - - /** - * @see org.apache.tuscany.sca.provider.PolicyProviderFactory#createReferencePolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.runtime.RuntimeComponentReference, org.apache.tuscany.sca.assembly.Binding) - */ - public PolicyProvider createReferencePolicyProvider(EndpointReference endpointReference) { - return new JDKLoggingReferencePolicyProvider(endpointReference); - } - - /** - * @see org.apache.tuscany.sca.provider.PolicyProviderFactory#createServicePolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.runtime.RuntimeComponentService, org.apache.tuscany.sca.assembly.Binding) - */ - public PolicyProvider createServicePolicyProvider(Endpoint endpoint) { - return new JDKLoggingServicePolicyProvider(endpoint); - } - - /** - * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType() - */ - public Class<JDKLoggingPolicy> getModelType() { - return JDKLoggingPolicy.class; - } - -} diff --git a/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingReferencePolicyProvider.java b/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingReferencePolicyProvider.java deleted file mode 100644 index 80867f57de..0000000000 --- a/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingReferencePolicyProvider.java +++ /dev/null @@ -1,45 +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.policy.logging.jdk; - -import java.util.List; - -import org.apache.tuscany.sca.assembly.EndpointReference; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.Phase; -import org.apache.tuscany.sca.invocation.PhasedInterceptor; -import org.apache.tuscany.sca.provider.BasePolicyProvider; - -/** - * @version $Rev$ $Date$ - */ -public class JDKLoggingReferencePolicyProvider extends BasePolicyProvider<JDKLoggingPolicy> { - - public JDKLoggingReferencePolicyProvider(EndpointReference endpointReference) { - super(JDKLoggingPolicy.class, endpointReference); - } - - public PhasedInterceptor createInterceptor(Operation operation) { - List<JDKLoggingPolicy> policies = findPolicies(); - return policies.isEmpty() ? null : new JDKLoggingPolicyInterceptor(subject, getContext(), operation, - policies, Phase.REFERENCE_POLICY); - } - -} diff --git a/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingServicePolicyProvider.java b/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingServicePolicyProvider.java deleted file mode 100644 index 99f0563603..0000000000 --- a/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingServicePolicyProvider.java +++ /dev/null @@ -1,44 +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.policy.logging.jdk; - -import java.util.List; - -import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.Phase; -import org.apache.tuscany.sca.invocation.PhasedInterceptor; -import org.apache.tuscany.sca.provider.BasePolicyProvider; - -/** - * @version $Rev$ $Date$ - */ -public class JDKLoggingServicePolicyProvider extends BasePolicyProvider<JDKLoggingPolicy> { - - public JDKLoggingServicePolicyProvider(Endpoint endpoint) { - super(JDKLoggingPolicy.class, endpoint); - } - - public PhasedInterceptor createInterceptor(Operation operation) { - List<JDKLoggingPolicy> policies = findPolicies(); - return policies.isEmpty() ? null : new JDKLoggingPolicyInterceptor(subject, getContext(), operation, policies, Phase.SERVICE_POLICY); - } - -} diff --git a/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.PolicyBuilder b/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.PolicyBuilder deleted file mode 100644 index f1fbc54a7a..0000000000 --- a/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.PolicyBuilder +++ /dev/null @@ -1,17 +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.
-org.apache.tuscany.sca.policy.logging.jdk.JDKLoggingPolicyBuilder;qname=http://tuscany.apache.org/xmlns/sca/1.1#jdkLogger
diff --git a/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor deleted file mode 100644 index 9d0a8fb67f..0000000000 --- a/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor +++ /dev/null @@ -1,20 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -# Implementation class for the artifact processor extension -org.apache.tuscany.sca.policy.logging.jdk.JDKLoggingPolicyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#jdkLogger,model=org.apache.tuscany.sca.policy.logging.jdk.JDKLoggingPolicy -
diff --git a/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions deleted file mode 100644 index bb7aed2087..0000000000 --- a/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions +++ /dev/null @@ -1,17 +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.
-org/apache/tuscany/sca/policy/logging/definitions.xml
diff --git a/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory b/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory deleted file mode 100644 index b9bb454550..0000000000 --- a/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory +++ /dev/null @@ -1,20 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Implementation class for the policy extension
-org.apache.tuscany.sca.policy.logging.jdk.JDKLoggingPolicyProviderFactory;model=org.apache.tuscany.sca.policy.logging.jdk.JDKLoggingPolicy
-
diff --git a/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/resources/org/apache/tuscany/sca/policy/logging/definitions.xml b/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/resources/org/apache/tuscany/sca/policy/logging/definitions.xml deleted file mode 100644 index 84b7f94e84..0000000000 --- a/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/main/resources/org/apache/tuscany/sca/policy/logging/definitions.xml +++ /dev/null @@ -1,38 +0,0 @@ -<?xml version="1.0" encoding="ASCII"?> -<!-- - * 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. ---> -<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" - targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1" - xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"> - - <!-- Policy Intents Defined by the Tuscany Runtime --> - <intent name="logging" constrains="implementation binding"> - <description> - All messages to and from this implementation must be logged - </description> - </intent> - - <!-- Policy Intents Defined by the Tuscany Runtime --> - <intent name="noLogging" constrains="implementation binding" excludes="tuscany:logging"> - <description> - All messages to and from this implementation must be logged - </description> - </intent> - -</definitions>
\ No newline at end of file diff --git a/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/test/java/org/apache/tuscany/sca/policy/logging/jdk/PolicyReadTestCase.java b/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/test/java/org/apache/tuscany/sca/policy/logging/jdk/PolicyReadTestCase.java deleted file mode 100644 index 0000ec8c06..0000000000 --- a/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/test/java/org/apache/tuscany/sca/policy/logging/jdk/PolicyReadTestCase.java +++ /dev/null @@ -1,94 +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.policy.logging.jdk; - - -import java.io.InputStream; -import java.io.StringReader; -import java.io.StringWriter; -import java.net.URL; -import java.util.logging.Level; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.contribution.processor.ProcessorContext; - -/** - * Test the reading of ws config params policy. - * - * @version $Rev$ $Date$ - */ -public class PolicyReadTestCase extends TestCase { - private ProcessorContext context = new ProcessorContext(); - - @Override - public void setUp() throws Exception { - } - - @Override - public void tearDown() throws Exception { - } - - public void testPolicyReading() throws Exception { - JDKLoggingPolicyProcessor processor = new JDKLoggingPolicyProcessor(null); - - URL url = getClass().getResource("mock_policies.xml"); - XMLInputFactory inputFactory = XMLInputFactory.newInstance(); - - InputStream urlStream = url.openStream(); - XMLStreamReader reader = inputFactory.createXMLStreamReader(urlStream); - - - JDKLoggingPolicy policy = processor.read(reader, context); - assertEquals(policy.getLoggerName(), "test.logger"); - assertEquals(policy.getLogLevel(), Level.INFO ); - assertEquals(policy.getResourceBundleName(), "Trace_Messages.properties"); - } - - public void testPolicyWriting() throws Exception { - JDKLoggingPolicyProcessor processor = new JDKLoggingPolicyProcessor(null); - - JDKLoggingPolicy policy = new JDKLoggingPolicy(); - policy.setLoggerName("test.logger"); - policy.setLogLevel(Level.INFO); - policy.setResourceBundleName("Trace_Messages.properties"); - - XMLOutputFactory outputFactory = XMLOutputFactory.newInstance(); - StringWriter sw = new StringWriter(); - XMLStreamWriter writer = outputFactory.createXMLStreamWriter(sw); - processor.write(policy, writer, context); - writer.close(); - - XMLInputFactory inputFactory = XMLInputFactory.newInstance(); - StringReader sr = new StringReader(sw.toString()); - XMLStreamReader reader = inputFactory.createXMLStreamReader(sr); - - policy = processor.read(reader, context); - assertEquals(policy.getLoggerName(), "test.logger"); - assertEquals(policy.getLogLevel(), Level.INFO ); - assertEquals(policy.getResourceBundleName(), "Trace_Messages.properties"); - - } - -} diff --git a/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/test/resources/org/apache/tuscany/sca/policy/logging/jdk/mock_policies.xml b/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/test/resources/org/apache/tuscany/sca/policy/logging/jdk/mock_policies.xml deleted file mode 100644 index 0f1c1f978c..0000000000 --- a/sca-java-2.x/tags/2.0-Beta3-RC2/modules/policy-logging/src/test/resources/org/apache/tuscany/sca/policy/logging/jdk/mock_policies.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="ASCII"?> -<!-- - * 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. ---> -<tuscany:jdkLogger xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" name="test.logger"> - <logLevel>INFO</logLevel> - <resourceBundle>Trace_Messages.properties</resourceBundle> -</tuscany:jdkLogger>
\ No newline at end of file |