Better solution for setting the context. The context is now known as soon as componen...
[utils] / system / spring / src / main / java / org / wamblee / system / spring / SpringComponent.java
index 0b0921e6dcd6abbb410ee56effb32e6c4f916b03..0e54deaec72ff12b194348704632f9bb8fdf7c4e 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2007 the original author or authors.
+ * 
+ * Licensed 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.wamblee.system.spring;
 
 import java.util.Map;
@@ -13,8 +28,6 @@ import org.springframework.context.support.GenericApplicationContext;
 import org.wamblee.system.AbstractComponent;
 import org.wamblee.system.ProvidedInterface;
 import org.wamblee.system.RequiredInterface;
-import org.wamblee.system.Service;
-import org.wamblee.system.SystemAssembler;
 import org.wamblee.system.SystemAssemblyException;
 
 /**
@@ -87,7 +100,7 @@ public class SpringComponent extends AbstractComponent {
        }
 
        @Override
-       protected void doStart(String aContext) {
+       protected void doStart() {
 
                SpringComponent old = THIS.get();
                THIS.set(this);
@@ -104,7 +117,7 @@ public class SpringComponent extends AbstractComponent {
                                        .addBeanFactoryPostProcessor(new PropertySetter(_properties));
                        _context.refresh();
 
-                       exposeProvidedServices(aContext);
+                       exposeProvidedServices();
                } catch (Exception e) {
                        throw new SystemAssemblyException(
                                        "Failed to assemble spring system", e);
@@ -113,16 +126,16 @@ public class SpringComponent extends AbstractComponent {
                }
        }
 
-       private void exposeProvidedServices(String aContext) {
+       private void exposeProvidedServices() {
                // Call addService for each provided service.
 
                for (String name : _provided.keySet()) {
                        Object svc = _context.getBean(name);
                        if (svc == null) {
-                               throw new IllegalArgumentException(aContext + ": service '"
+                               throw new IllegalArgumentException(getQualifiedName() + ": service '"
                                                + name + "' is null");
                        }
-                       addService(aContext, _provided.get(name), svc);
+                       addService(_provided.get(name), svc);
                }
        }