00001 package cast.server;
00002
00003 import Ice.Current;
00004 import Ice.LocalObjectHolder;
00005 import Ice.Object;
00006 import Ice.ServantLocator;
00007 import Ice.UserException;
00008 import cast.core.CASTUtils;
00009
00010 public class ComponentLocator implements ServantLocator {
00011
00012 public ComponentLocator() {
00013 }
00014
00015 public void deactivate(String _arg0) {
00016
00017 }
00018
00019 public void finished(Current _arg0, Object _arg1, java.lang.Object _arg2)
00020 throws UserException {
00021
00022 }
00023
00024 public int ice_hash() {
00025 return hashCode();
00026 }
00027
00028 public Object locate(Current _current, LocalObjectHolder _arg1) {
00029 synchronized (this) {
00030
00031 String name = _current.id.name;
00032 String cat = _current.id.category;
00033
00034
00035
00036 Object servant = _current.adapter.find(_current.id);
00037 if (servant == null) {
00038 try {
00039 servant = CASTUtils.createServant(_current.id, _current.adapter);
00040 if (servant != null) {
00041 _current.adapter.add(servant, _current.id);
00042 }
00043 } catch (Exception e) {
00044 throw new RuntimeException("Error creating component "
00045 + name + " of class " + cat + ". Exception error: "
00046 + e.getLocalizedMessage(), e);
00047 }
00048 }
00049
00050 assert (servant != null);
00051
00052 return servant;
00053 }
00054 }
00055
00056
00057 }