From 700ac7a6899a4db2e94e191fe4a518d6d9ed302e Mon Sep 17 00:00:00 2001 From: antelder Date: Mon, 11 Aug 2008 07:21:22 +0000 Subject: Start getting implementation-web to work with the new model git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@684655 13f79535-47bb-0310-9956-ffa450edef68 --- .../web/runtime/ComponentContextProxy.java | 77 ++++++++++++++++++++++ .../runtime/WebImplementationProviderFactory.java | 57 ++++++++++++++++ ...cany.sca.provider.ImplementationProviderFactory | 19 ++++++ 3 files changed, 153 insertions(+) create mode 100644 java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/ComponentContextProxy.java create mode 100644 java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/WebImplementationProviderFactory.java create mode 100644 java/sca/modules/implementation-web-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory (limited to 'java/sca/modules/implementation-web-runtime/src') diff --git a/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/ComponentContextProxy.java b/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/ComponentContextProxy.java new file mode 100644 index 0000000000..59afe23fa4 --- /dev/null +++ b/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/ComponentContextProxy.java @@ -0,0 +1,77 @@ +/* + * 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.implementation.web.runtime; + +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.osoa.sca.CallableReference; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.RequestContext; +import org.osoa.sca.ServiceReference; + +/** + * Proxy ComponentContext wrappering a RuntimeComponent as the + * RuntimeComponent ComponentContext has not been created till later + */ +public class ComponentContextProxy implements ComponentContext { + + protected RuntimeComponent runtimeComponent; + + public ComponentContextProxy(RuntimeComponent runtimeComponent) { + this.runtimeComponent = runtimeComponent; + } + + protected ComponentContext getComponentContext() { + return runtimeComponent.getComponentContext(); + } + + @SuppressWarnings("unchecked") + public > R cast(B arg0) throws IllegalArgumentException { + return (R) getComponentContext().cast(arg0); + } + + public ServiceReference createSelfReference(Class arg0) { + return getComponentContext().createSelfReference(arg0); + } + + public ServiceReference createSelfReference(Class arg0, String arg1) { + return getComponentContext().createSelfReference(arg0, arg1); + } + + public B getProperty(Class arg0, String arg1) { + return getComponentContext().getProperty(arg0, arg1); + } + + public RequestContext getRequestContext() { + return getComponentContext().getRequestContext(); + } + + public B getService(Class arg0, String arg1) { + return getComponentContext().getService(arg0, arg1); + } + + public ServiceReference getServiceReference(Class arg0, String arg1) { + return getComponentContext().getServiceReference(arg0, arg1); + } + + public String getURI() { + return getComponentContext().getURI(); + } + +} diff --git a/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/WebImplementationProviderFactory.java b/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/WebImplementationProviderFactory.java new file mode 100644 index 0000000000..18a1bd3326 --- /dev/null +++ b/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/WebImplementationProviderFactory.java @@ -0,0 +1,57 @@ +/* + * 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.implementation.web.runtime; + +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.host.webapp.WebAppServletHost; +import org.apache.tuscany.sca.implementation.web.WebImplementation; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.provider.ImplementationProvider; +import org.apache.tuscany.sca.provider.ImplementationProviderFactory; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; +public class WebImplementationProviderFactory implements ImplementationProviderFactory { + + public WebImplementationProviderFactory(ExtensionPointRegistry extensionPoints) { + } + + public ImplementationProvider createImplementationProvider(RuntimeComponent component, WebImplementation implementation) { + + WebAppServletHost.getInstance().setAttribute("org.osoa.sca.ComponentContext", new ComponentContextProxy(component)); + + return new ImplementationProvider() { + public Invoker createInvoker(RuntimeComponentService arg0, Operation arg1) { + throw new UnsupportedOperationException("Components using implementation.web have no services"); + } + public void start() { + } + public void stop() { + } + public boolean supportsOneWayInvocation() { + return false; + } + }; + } + + public Class getModelType() { + return WebImplementation.class; + } + +} diff --git a/java/sca/modules/implementation-web-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/java/sca/modules/implementation-web-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory new file mode 100644 index 0000000000..9b769c9b10 --- /dev/null +++ b/java/sca/modules/implementation-web-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory @@ -0,0 +1,19 @@ +# 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 implementation extension +org.apache.tuscany.sca.implementation.web.runtime.WebImplementationProviderFactory;model=org.apache.tuscany.sca.implementation.web.WebImplementation -- cgit v1.2.3