PDA

View Full Version : Entreprise Services


Bruno Baia
11-25-2005, 02:17 PM
Hi,

I don't find a forum to talk about Entreprise Services support (Spring.Entreprise), so i'll ask my question here :)

Is there a sample in CVS that comes with this page :
http://opensource2.atlassian.com/confluence/spring/display/NET/Enterprise+Services+Support ?

thks

Aleks Seovic
11-25-2005, 02:55 PM
Hi Bruno,

I don't think there is, but we definitely need to provide one as part of 1.1 release.

- Aleks

Bruno Baia
11-25-2005, 03:47 PM
oki.

I tried ot make it work but i got always the same error when registering the library :
TypeLoadException ("One or more of the types in the assembly unable to load").
So i'll wait for the sample.


Anyway, there is something that i don't understand in the sample :
http://opensource2.atlassian.com/confluence/spring/display/NET/Enterprise+Services+Support

The ServicedComponentExporter will create a composition proxy for the SimpleUserManager class that extends ServicedComponents.
The constructor looks like :


public Customers()
{
this.__proxyTarget = new SimpleUserManager();
}


So How (or when) it will take into account the dependency injection defined in the config file ?


<object id="userManager" type="MyApp.Services.SimpleUserManager">
<property name="UserDao"><ref object="userDao"/></property>
</object>


Am i missing something ?

Aleks Seovic
11-25-2005, 04:05 PM
Hi Bruno,

Take a look at the example in src\POC\EnterpriseServices directory. It's not a real example (more of a test case, really), so I didn't want to add it to the examples directory.

As for dependency injection, it is done by the Spring.Enterprise.ServicedComponentFactory class based on the value of the Template property.

HTH,

Aleks

Bruno Baia
11-25-2005, 04:34 PM
Ok, i didn't look the "factory" part without make work the "registering" part :oops: .

In the sample everything is in the same application, and i'm on a "service locator" situation (i know, i'm boring with that :lol: ), so i made a Console Application that will register the component service, and i got a client application that will only need this part of the config file :


<object id="MyEnterpriseService" type="Spring.Enterprise.ServicedComponentFactory, Spring.Services">
<property name="Name"><value>EnterpriseServices.ServiceOne</value></property>
</object>


and i don't have the template here, i configured it in the registering application config file.

Bruno, the smiley addict :)

Bruno Baia
11-28-2005, 10:39 AM
I tried ot make it work but i got always the same error when registering the library :
TypeLoadException ("One or more of the types in the assembly unable to load").
resolved by signing all referenced assemblies.

-----------------

So i tried to call the COM+ component registered, and i got this error while trying to make the dependency injection :

Property 'UserDao' is not writable in class [MyApp.EnterpriseServices.UserManager]

The composition Proxy don't generate the property, so i added the definition in the interface :

public interface IUserManager
{
IUserDao UserDao { set; }
User GetUser(int userId);
void SaveUser(User user);
}


But the property, generated in the proxy, got a wrong name :
'MyApp.Services.IUserManager.UserDao'
So i changed the 'ImplementProperty' method of the 'AbstractProxyTypeBuilder' Class :


PropertyBuilder pb = typeBuilder.DefineProperty(intf.FullName + "." + property.Name,
PropertyAttributes.None, property.PropertyType,
ReflectionUtils.GetParameterTypes(property.GetInde xParameters()));

by

PropertyBuilder pb = typeBuilder.DefineProperty(property.Name,
PropertyAttributes.None, property.PropertyType,
ReflectionUtils.GetParameterTypes(property.GetInde xParameters()));


finally, i had to remove the AutoComplete attribute and it works :)

Aleks Seovic
11-28-2005, 07:23 PM
Everything looks good except for the last change...

You should've just set ExplicitInterfaceImplementation property on the proxy builder to false -- there are cases when you want it, but in this case you don't, so it has to be controlled by the flag instead of by modifying the code to do it the way you need right now...

Later,

Aleks

Bruno Baia
11-29-2005, 09:42 AM
ExplicitInterfaceImplementation seems to be only used for ImplementMethod, not for ImplementProperty or ImplementEvent.