From e0ff67c0b32813ea48734c770a5ffc1952644e29 Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:08:02 +0000 Subject: Moving 1.x branches git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835128 13f79535-47bb-0310-9956-ffa450edef68 --- .../logging/LoggingPolicyDefinitionsProvider.java | 67 ---------- .../JDKLoggingImplementationPolicyProvider.java | 90 -------------- .../sca/policy/logging/jdk/JDKLoggingPolicy.java | 84 ------------- .../logging/jdk/JDKLoggingPolicyInterceptor.java | 130 ------------------- .../logging/jdk/JDKLoggingPolicyProcessor.java | 137 --------------------- .../jdk/JDKLoggingPolicyProviderFactory.java | 75 ----------- .../jdk/JDKLoggingReferencePolicyProvider.java | 89 ------------- .../jdk/JDKLoggingServicePolicyProvider.java | 87 ------------- 8 files changed, 759 deletions(-) delete mode 100644 branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/LoggingPolicyDefinitionsProvider.java delete mode 100644 branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingImplementationPolicyProvider.java delete mode 100644 branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicy.java delete mode 100644 branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyInterceptor.java delete mode 100644 branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProcessor.java delete mode 100644 branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProviderFactory.java delete mode 100644 branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingReferencePolicyProvider.java delete mode 100644 branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingServicePolicyProvider.java (limited to 'branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache') diff --git a/branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/LoggingPolicyDefinitionsProvider.java b/branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/LoggingPolicyDefinitionsProvider.java deleted file mode 100644 index 4220caab80..0000000000 --- a/branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/LoggingPolicyDefinitionsProvider.java +++ /dev/null @@ -1,67 +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 java.net.URI; -import java.net.URL; -import java.security.AccessController; -import java.security.PrivilegedAction; - -import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.definitions.SCADefinitions; -import org.apache.tuscany.sca.provider.SCADefinitionsProvider; -import org.apache.tuscany.sca.provider.SCADefinitionsProviderException; - -/** - * Provider for Policy Intents and PolicySet definitions related to security - * - * @version $Rev$ $Date$ - */ -public class LoggingPolicyDefinitionsProvider implements SCADefinitionsProvider { - private String definitionsFile = "org/apache/tuscany/sca/policy/logging/definitions.xml"; - URLArtifactProcessor urlArtifactProcessor = null; - - public LoggingPolicyDefinitionsProvider(ExtensionPointRegistry registry) { - URLArtifactProcessorExtensionPoint documentProcessors = registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); - urlArtifactProcessor = (URLArtifactProcessor)documentProcessors.getProcessor(SCADefinitions.class); - } - - public SCADefinitions getSCADefinition() throws SCADefinitionsProviderException { - // Allow privileged access to load resource. Requires RuntimePermssion in security policy. - URL definitionsFileUrl = AccessController.doPrivileged(new PrivilegedAction() { - public URL run() { - return getClass().getClassLoader().getResource(definitionsFile); - } - }); - - Object scaDefn = null; - try { - URI uri = new URI(definitionsFile); - return (SCADefinitions)urlArtifactProcessor.read(null, - uri, - definitionsFileUrl); - } catch ( Exception e ) { - throw new SCADefinitionsProviderException(e); - } - } - -} diff --git a/branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingImplementationPolicyProvider.java b/branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingImplementationPolicyProvider.java deleted file mode 100644 index c53c37ccf6..0000000000 --- a/branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingImplementationPolicyProvider.java +++ /dev/null @@ -1,90 +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.ConfiguredOperation; -import org.apache.tuscany.sca.assembly.Implementation; -import org.apache.tuscany.sca.assembly.OperationsConfigurator; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.Interceptor; -import org.apache.tuscany.sca.invocation.Phase; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.provider.PolicyProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; - -/** - * @version $Rev$ $Date$ - */ -public class JDKLoggingImplementationPolicyProvider implements PolicyProvider { - private RuntimeComponent component; - private Implementation implementation; - - public JDKLoggingImplementationPolicyProvider(RuntimeComponent component, Implementation implementation) { - super(); - this.component = component; - this.implementation = implementation; - } - - private String getContext() { - return "component.implementation: " + component.getURI() + "(" + implementation.getClass().getName() + ")"; - } - - private PolicySet findPolicySet(Operation operation) { - for (PolicySet ps : component.getPolicySets()) { - for (Object p : ps.getPolicies()) { - if (JDKLoggingPolicy.class.isInstance(p)) { - return ps; - } - } - } - - if ( component instanceof OperationsConfigurator ) { - for ( ConfiguredOperation confOp : ((OperationsConfigurator)component).getConfiguredOperations() ) { - if ( confOp.getName().equals(operation.getName())) { - for (PolicySet ps : confOp.getPolicySets()) { - for (Object p : ps.getPolicies()) { - if (JDKLoggingPolicy.class.isInstance(p)) { - return ps; - } - } - } - } - } - } - - return null; - } - - /** - * @see org.apache.tuscany.sca.provider.PolicyProvider#createInterceptor(org.apache.tuscany.sca.interfacedef.Operation) - */ - public Interceptor createInterceptor(Operation operation) { - PolicySet ps = findPolicySet(operation); - return ps == null ? null : new JDKLoggingPolicyInterceptor(getContext(), operation, ps); - } - - /** - * @see org.apache.tuscany.sca.provider.PolicyProvider#getPhase() - */ - public String getPhase() { - return Phase.IMPLEMENTATION_POLICY; - } - -} diff --git a/branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicy.java b/branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicy.java deleted file mode 100644 index 731b2d8d62..0000000000 --- a/branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicy.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.logging.Level; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.assembly.xml.Constants; -import org.apache.tuscany.sca.policy.Policy; - -/** - * Implementation for policies that could be injected as parameter - * into the axis2config. - * - * @version $Rev$ $Date$ - */ -public class JDKLoggingPolicy implements Policy { - private static final QName JDK_LOGGING_POLICY_QNAME = new QName(Constants.SCA10_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) { - } -} diff --git a/branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyInterceptor.java b/branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyInterceptor.java deleted file mode 100644 index 58a6d21ee7..0000000000 --- a/branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyInterceptor.java +++ /dev/null @@ -1,130 +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.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.xml.Constants; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.Interceptor; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.policy.PolicySet; - -/** - * Policy handler to handle PolicySet related to Logging with the QName - * {http://tuscany.apache.org/xmlns/sca/1.0/impl/java}LoggingPolicy - * - * @version $Rev$ $Date$ - */ -public class JDKLoggingPolicyInterceptor implements Interceptor { - public static final String loggingPolicy = "JDKLoggingPolicy"; - public static final QName policySetQName = new QName(Constants.SCA10_TUSCANY_NS, loggingPolicy); - private Logger logger = null; - - private Invoker next; - private Operation operation; - private PolicySet policySet = null; - private String context; - - public JDKLoggingPolicyInterceptor(String context, Operation operation, PolicySet policySet) { - super(); - this.operation = operation; - this.policySet = policySet; - this.context = context; - init(); - } - - private void init() { - if (policySet != null) { - JDKLoggingPolicy policy = (JDKLoggingPolicy)policySet.getPolicies().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); - } - } - } - - public Message invoke(Message msg) { - if (logger == null) { - return getNext().invoke(msg); - } - Object msgBody = msg.getBody(); - if (msgBody instanceof Object[]) { - logger.logp(Level.INFO, context, "", "Invoking operation - " + operation.getName()); - - 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.FINER, 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) { - Object[] logParams = new Object[] {operation.getName(), responseMsg.getBody()}; - logger.logp(Level.INFO, context, "", "Returned from operation - " + operation.getName()); - logger.logp(Level.FINER, context, "", "Returning from operation {0} with return value {1}", logParams); - } - } - } - - public Invoker getNext() { - return next; - } - - public void setNext(Invoker next) { - this.next = next; - } -} diff --git a/branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProcessor.java b/branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProcessor.java deleted file mode 100644 index 83526e0f03..0000000000 --- a/branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProcessor.java +++ /dev/null @@ -1,137 +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.assembly.xml.Constants; -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; -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.monitor.Monitor; - -/** - * - * @version $Rev$ $Date$ - */ -public class JDKLoggingPolicyProcessor implements StAXArtifactProcessor { - private static final QName JDK_LOGGING_POLICY_QNAME = new QName(Constants.SCA10_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"; - private static final String TUSACNY_NS = "http://tuscany.apache.org/xmlns/sca/1.0"; - - public QName getArtifactType() { - return JDK_LOGGING_POLICY_QNAME; - } - - public JDKLoggingPolicyProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) { - } - - - public JDKLoggingPolicy read(XMLStreamReader reader) 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, Constants.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.getBoolean(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) throws ContributionWriteException, - XMLStreamException { - String prefix = "tuscany"; - writer.writeStartElement(prefix, - JDK_LOGGING_POLICY_QNAME.getLocalPart(), - JDK_LOGGING_POLICY_QNAME.getNamespaceURI()); - writer.writeNamespace("tuscany", Constants.SCA10_TUSCANY_NS); - - if (policy.getLoggerName() != null) { - writer.writeAttribute(Constants.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 getModelType() { - return JDKLoggingPolicy.class; - } - - public void resolve(JDKLoggingPolicy arg0, ModelResolver arg1) throws ContributionResolveException { - - } - -} diff --git a/branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProviderFactory.java b/branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProviderFactory.java deleted file mode 100644 index 9bbae8956f..0000000000 --- a/branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProviderFactory.java +++ /dev/null @@ -1,75 +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.Binding; -import org.apache.tuscany.sca.assembly.Implementation; -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; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; - -/** - * @version $Rev$ $Date$ - */ -public class JDKLoggingPolicyProviderFactory implements PolicyProviderFactory { - 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, Implementation implementation) { - return new JDKLoggingImplementationPolicyProvider(component, implementation); - } - - /** - * @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(RuntimeComponent component, - RuntimeComponentReference reference, - Binding binding) { - return new JDKLoggingReferencePolicyProvider(component, reference, binding); - } - - /** - * @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(RuntimeComponent component, - RuntimeComponentService service, - Binding binding) { - return new JDKLoggingServicePolicyProvider(component, service, binding); - } - - /** - * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType() - */ - public Class getModelType() { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingReferencePolicyProvider.java b/branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingReferencePolicyProvider.java deleted file mode 100644 index feddc8c056..0000000000 --- a/branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingReferencePolicyProvider.java +++ /dev/null @@ -1,89 +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.Binding; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.Interceptor; -import org.apache.tuscany.sca.invocation.Phase; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySetAttachPoint; -import org.apache.tuscany.sca.provider.PolicyProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; - -/** - * @version $Rev$ $Date$ - */ -public class JDKLoggingReferencePolicyProvider implements PolicyProvider { - private RuntimeComponent component; - private RuntimeComponentReference reference; - private Binding binding; - - public JDKLoggingReferencePolicyProvider(RuntimeComponent component, - RuntimeComponentReference reference, - Binding binding) { - super(); - this.component = component; - this.reference = reference; - this.binding = binding; - } - - private PolicySet findPolicySet() { - if (binding instanceof PolicySetAttachPoint) { - List policySets = ((PolicySetAttachPoint)binding).getApplicablePolicySets(); - for (PolicySet ps : policySets) { - for (Object p : ps.getPolicies()) { - if (JDKLoggingPolicy.class.isInstance(p)) { - return ps; - } - } - } - } - return null; - } - - private String getContext() { - return "component.reference: " + component.getURI() - + "#" - + reference.getName() - + "(" - + binding.getClass().getName() - + ")"; - } - - /** - * @see org.apache.tuscany.sca.provider.PolicyProvider#createInterceptor(org.apache.tuscany.sca.interfacedef.Operation) - */ - public Interceptor createInterceptor(Operation operation) { - PolicySet ps = findPolicySet(); - return ps == null ? null : new JDKLoggingPolicyInterceptor(getContext(), operation, ps); - } - - /** - * @see org.apache.tuscany.sca.provider.PolicyProvider#getPhase() - */ - public String getPhase() { - return Phase.REFERENCE_POLICY; - } - -} diff --git a/branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingServicePolicyProvider.java b/branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingServicePolicyProvider.java deleted file mode 100644 index 472f76c680..0000000000 --- a/branches/sca-java-1.3.1/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingServicePolicyProvider.java +++ /dev/null @@ -1,87 +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.Binding; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.Interceptor; -import org.apache.tuscany.sca.invocation.Phase; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySetAttachPoint; -import org.apache.tuscany.sca.provider.PolicyProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; - -/** - * @version $Rev$ $Date$ - */ -public class JDKLoggingServicePolicyProvider implements PolicyProvider { - private RuntimeComponent component; - private RuntimeComponentService service; - private Binding binding; - - public JDKLoggingServicePolicyProvider(RuntimeComponent component, RuntimeComponentService service, Binding binding) { - super(); - this.component = component; - this.service = service; - this.binding = binding; - } - - private PolicySet findPolicySet() { - if (binding instanceof PolicySetAttachPoint) { - List policySets = ((PolicySetAttachPoint)binding).getApplicablePolicySets(); - for (PolicySet ps : policySets) { - for (Object p : ps.getPolicies()) { - if (JDKLoggingPolicy.class.isInstance(p)) { - return ps; - } - } - } - } - return null; - } - - private String getContext() { - return "component.service: " + component.getURI() - + "#" - + service.getName() - + "(" - + binding.getClass().getName() - + ")"; - } - - /** - * @see org.apache.tuscany.sca.provider.PolicyProvider#createInterceptor(org.apache.tuscany.sca.interfacedef.Operation) - */ - public Interceptor createInterceptor(Operation operation) { - PolicySet ps = findPolicySet(); - return ps == null ? null : new JDKLoggingPolicyInterceptor(getContext(), operation, ps); - } - - /** - * @see org.apache.tuscany.sca.provider.PolicyProvider#getPhase() - */ - public String getPhase() { - return Phase.SERVICE_POLICY; - } - -} -- cgit v1.2.3