From 9dafe3e2c4d2476cb3ea7789e3f3063418340059 Mon Sep 17 00:00:00 2001 From: rfeng Date: Wed, 28 Jul 2010 21:01:41 +0000 Subject: Allow Spring WebApplicationContext to be used by Tuscany Bring up a sample web application which demonstrates the integration between Spring and Tuscany git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@980218 13f79535-47bb-0310-9956-ffa450edef68 --- .../spring/webapp/ApplicationContextAccessor.java | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/implementation/spring/webapp/ApplicationContextAccessor.java (limited to 'sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/implementation/spring/webapp/ApplicationContextAccessor.java') diff --git a/sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/implementation/spring/webapp/ApplicationContextAccessor.java b/sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/implementation/spring/webapp/ApplicationContextAccessor.java new file mode 100644 index 0000000000..e2f748aba8 --- /dev/null +++ b/sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/implementation/spring/webapp/ApplicationContextAccessor.java @@ -0,0 +1,43 @@ +/* + * 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.spring.webapp; + +import org.springframework.context.ApplicationContextAware; +import org.springframework.context.support.ApplicationObjectSupport; + +/** + * A singleton utility class that can be added to the Spring application context to receive injection of the containing + * Spring application context. + * + * The Spring bean definition file is: org/apache/tuscany/sca/implementation/spring/webapp/spring-webapp-context.xml + */ +public class ApplicationContextAccessor extends ApplicationObjectSupport implements ApplicationContextAware { + public final static String BEAN_ID = "tuscanySpringApplicationContextAccessor"; + private final static ApplicationContextAccessor INSTANCE = new ApplicationContextAccessor(); + + private ApplicationContextAccessor() { + } + + // Spring static factory method to create the singleton instance + public static ApplicationContextAccessor getInstance() { + return INSTANCE; + } + +} -- cgit v1.2.3