Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » CDO / Net4J socket connector
CDO / Net4J socket connector [message #53480] Wed, 27 September 2006 08:01 Go to next message
Eclipse UserFriend
Originally posted by: yannick.lizzi.silogic.fr

Hi all,

I want to develop a CDO/Net4J client that connects to a CDO/Net4J
server. When the client application starts, it doesn't know the server
host and port.
So comparing to the CDO examples, I have to customize the
ActiveSocketConnector programmatically (not via Spring) by setting host
and port, while the CDO client starts.
How can I do this?

I tried to set host and port before the resourceManager.start() by the
following code:
ActiveSocketConnector conn = (ActiveSocketConnector)
resourceManager.getChannel().getConnector();
conn.setHost(host);
conn.setPort(port);
The problem is that the connector have already started to connect with
the information taken from client.properties.

I also tried to comment the connector bean in client.xml and create it
programmatically with the following code:
ActiveSocketConnectorImpl connector = new ActiveSocketConnectorImpl();
connector.setHost(host);
connector.setPort(port);
connector.setProtocolManager(clientContainer.getBean("protocolManager "));
connector.setSelectorManager(clientContainer.getBean("selectorManager "));
connector.setBufferPool(clientContainer.getBean("bufferPool "));
resourceManager.setConnector(connector);

But in this case, I get a NoControlProtocolException when creating the
resource.

So what's the right way?

Thanks

Yannick Lizzi
Re: CDO / Net4J socket connector [message #53533 is a reply to message #53480] Wed, 27 September 2006 12:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: stepper.sympedia.de

Yannick,

Open the file /org.eclipse.emf.cdo.examples.client/META-INF/client.xml
and change the following:

<!-- ######################################################## -->
<bean id="connector" class="org.eclipse.net4j.socket.impl.ActiveSocketConnectorImpl ">
<property name="bufferPool">
<ref bean="bufferPool"/>
</property>
<property name="protocolManager">
<ref bean="protocolManager"/>
</property>
<property name="selectorManager">
<ref bean="selectorManager"/>
</property>
<!-- REMOVED
<property name="host">
<value>${connector.host}</value>
</property>
<property name="port">
<value>${connector.port}</value>
</property>
-->
<property name="autoStart"> <!-- ADDED -->
<value>false</value>
</property> -->
</bean>

This creates a Connector that is not automatically started when the container is started.
But don't forget to start it manually (ExampleClientPlugin) prior to service calls:

private static ActiveSocketConnector cachedConnector;

public static Connector getConnector()
{
if (cachedConnector == null)
{
cachedConnector = (ActiveSocketConnector) getClientContainer().getBean("connector");
cachedConnector.setHost("net4j.acme.com");
cachedConnector.setPort(12345);

try
{
cachedConnector.start();
}
catch (Exception ex)
{
ex.printStackTrace();
cachedConnector = null;
}
}

return cachedConnector;
}

I hope this helps.

Cheers
/Eike



Yannick Lizzi schrieb:
> Hi all,
>
> I want to develop a CDO/Net4J client that connects to a CDO/Net4J
> server. When the client application starts, it doesn't know the server
> host and port.
> So comparing to the CDO examples, I have to customize the
> ActiveSocketConnector programmatically (not via Spring) by setting host
> and port, while the CDO client starts.
> How can I do this?
>
> I tried to set host and port before the resourceManager.start() by the
> following code:
> ActiveSocketConnector conn = (ActiveSocketConnector)
> resourceManager.getChannel().getConnector();
> conn.setHost(host);
> conn.setPort(port);
> The problem is that the connector have already started to connect with
> the information taken from client.properties.
>
> I also tried to comment the connector bean in client.xml and create it
> programmatically with the following code:
> ActiveSocketConnectorImpl connector = new ActiveSocketConnectorImpl();
> connector.setHost(host);
> connector.setPort(port);
> connector.setProtocolManager(clientContainer.getBean("protocolManager "));
> connector.setSelectorManager(clientContainer.getBean("selectorManager "));
> connector.setBufferPool(clientContainer.getBean("bufferPool "));
> resourceManager.setConnector(connector);
>
> But in this case, I get a NoControlProtocolException when creating the
> resource.
>
> So what's the right way?
>
> Thanks
>
> Yannick Lizzi
Re: CDO / Net4J socket connector [message #53640 is a reply to message #53533] Wed, 27 September 2006 15:49 Go to previous message
Eclipse UserFriend
Originally posted by: yannick.lizzi.silogic.fr

Eike

Thanks it works.

Yannick


> Yannick,
>
> Open the file /org.eclipse.emf.cdo.examples.client/META-INF/client.xml
> and change the following:
>
> <!-- ######################################################## -->
> <bean id="connector"
> class="org.eclipse.net4j.socket.impl.ActiveSocketConnectorImpl ">
> <property name="bufferPool">
> <ref bean="bufferPool"/>
> </property>
> <property name="protocolManager">
> <ref bean="protocolManager"/>
> </property>
> <property name="selectorManager">
> <ref bean="selectorManager"/>
> </property>
> <!-- REMOVED
> <property name="host">
> <value>${connector.host}</value>
> </property>
> <property name="port">
> <value>${connector.port}</value>
> </property>
> -->
> <property name="autoStart"> <!-- ADDED -->
> <value>false</value>
> </property> -->
> </bean>
>
> This creates a Connector that is not automatically started when the
> container is started.
> But don't forget to start it manually (ExampleClientPlugin) prior to
> service calls:
>
> private static ActiveSocketConnector cachedConnector;
>
> public static Connector getConnector()
> {
> if (cachedConnector == null)
> {
> cachedConnector = (ActiveSocketConnector)
> getClientContainer().getBean("connector");
> cachedConnector.setHost("net4j.acme.com");
> cachedConnector.setPort(12345);
>
> try
> {
> cachedConnector.start();
> }
> catch (Exception ex)
> {
> ex.printStackTrace();
> cachedConnector = null;
> }
> }
>
> return cachedConnector;
> }
>
> I hope this helps.
>
> Cheers
> /Eike
>
>
>
> Yannick Lizzi schrieb:
>> Hi all,
>>
>> I want to develop a CDO/Net4J client that connects to a CDO/Net4J
>> server. When the client application starts, it doesn't know the server
>> host and port.
>> So comparing to the CDO examples, I have to customize the
>> ActiveSocketConnector programmatically (not via Spring) by setting
>> host and port, while the CDO client starts.
>> How can I do this?
>>
>> I tried to set host and port before the resourceManager.start() by the
>> following code:
>> ActiveSocketConnector conn = (ActiveSocketConnector)
>> resourceManager.getChannel().getConnector();
>> conn.setHost(host);
>> conn.setPort(port);
>> The problem is that the connector have already started to connect with
>> the information taken from client.properties.
>>
>> I also tried to comment the connector bean in client.xml and create it
>> programmatically with the following code:
>> ActiveSocketConnectorImpl connector = new ActiveSocketConnectorImpl();
>> connector.setHost(host);
>> connector.setPort(port);
>> connector.setProtocolManager(clientContainer.getBean("protocolManager "));
>> connector.setSelectorManager(clientContainer.getBean("selectorManager "));
>> connector.setBufferPool(clientContainer.getBean("bufferPool "));
>> resourceManager.setConnector(connector);
>>
>> But in this case, I get a NoControlProtocolException when creating the
>> resource.
>>
>> So what's the right way?
>>
>> Thanks
>>
>> Yannick Lizzi
Re: CDO / Net4J socket connector [message #592300 is a reply to message #53480] Wed, 27 September 2006 12:26 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6690
Registered: July 2009
Senior Member
Yannick,

Open the file /org.eclipse.emf.cdo.examples.client/META-INF/client.xml
and change the following:

<!-- ######################################################## -->
<bean id="connector" class="org.eclipse.net4j.socket.impl.ActiveSocketConnectorImpl ">
<property name="bufferPool">
<ref bean="bufferPool"/>
</property>
<property name="protocolManager">
<ref bean="protocolManager"/>
</property>
<property name="selectorManager">
<ref bean="selectorManager"/>
</property>
<!-- REMOVED
<property name="host">
<value>${connector.host}</value>
</property>
<property name="port">
<value>${connector.port}</value>
</property>
-->
<property name="autoStart"> <!-- ADDED -->
<value>false</value>
</property> -->
</bean>

This creates a Connector that is not automatically started when the container is started.
But don't forget to start it manually (ExampleClientPlugin) prior to service calls:

private static ActiveSocketConnector cachedConnector;

public static Connector getConnector()
{
if (cachedConnector == null)
{
cachedConnector = (ActiveSocketConnector) getClientContainer().getBean("connector");
cachedConnector.setHost("net4j.acme.com");
cachedConnector.setPort(12345);

try
{
cachedConnector.start();
}
catch (Exception ex)
{
ex.printStackTrace();
cachedConnector = null;
}
}

return cachedConnector;
}

I hope this helps.

Cheers
/Eike



Yannick Lizzi schrieb:
> Hi all,
>
> I want to develop a CDO/Net4J client that connects to a CDO/Net4J
> server. When the client application starts, it doesn't know the server
> host and port.
> So comparing to the CDO examples, I have to customize the
> ActiveSocketConnector programmatically (not via Spring) by setting host
> and port, while the CDO client starts.
> How can I do this?
>
> I tried to set host and port before the resourceManager.start() by the
> following code:
> ActiveSocketConnector conn = (ActiveSocketConnector)
> resourceManager.getChannel().getConnector();
> conn.setHost(host);
> conn.setPort(port);
> The problem is that the connector have already started to connect with
> the information taken from client.properties.
>
> I also tried to comment the connector bean in client.xml and create it
> programmatically with the following code:
> ActiveSocketConnectorImpl connector = new ActiveSocketConnectorImpl();
> connector.setHost(host);
> connector.setPort(port);
> connector.setProtocolManager(clientContainer.getBean("protocolManager "));
> connector.setSelectorManager(clientContainer.getBean("selectorManager "));
> connector.setBufferPool(clientContainer.getBean("bufferPool "));
> resourceManager.setConnector(connector);
>
> But in this case, I get a NoControlProtocolException when creating the
> resource.
>
> So what's the right way?
>
> Thanks
>
> Yannick Lizzi


Re: CDO / Net4J socket connector [message #592358 is a reply to message #53533] Wed, 27 September 2006 15:49 Go to previous message
Eclipse UserFriend
Originally posted by: yannick.lizzi.silogic.fr

Eike

Thanks it works.

Yannick


> Yannick,
>
> Open the file /org.eclipse.emf.cdo.examples.client/META-INF/client.xml
> and change the following:
>
> <!-- ######################################################## -->
> <bean id="connector"
> class="org.eclipse.net4j.socket.impl.ActiveSocketConnectorImpl ">
> <property name="bufferPool">
> <ref bean="bufferPool"/>
> </property>
> <property name="protocolManager">
> <ref bean="protocolManager"/>
> </property>
> <property name="selectorManager">
> <ref bean="selectorManager"/>
> </property>
> <!-- REMOVED
> <property name="host">
> <value>${connector.host}</value>
> </property>
> <property name="port">
> <value>${connector.port}</value>
> </property>
> -->
> <property name="autoStart"> <!-- ADDED -->
> <value>false</value>
> </property> -->
> </bean>
>
> This creates a Connector that is not automatically started when the
> container is started.
> But don't forget to start it manually (ExampleClientPlugin) prior to
> service calls:
>
> private static ActiveSocketConnector cachedConnector;
>
> public static Connector getConnector()
> {
> if (cachedConnector == null)
> {
> cachedConnector = (ActiveSocketConnector)
> getClientContainer().getBean("connector");
> cachedConnector.setHost("net4j.acme.com");
> cachedConnector.setPort(12345);
>
> try
> {
> cachedConnector.start();
> }
> catch (Exception ex)
> {
> ex.printStackTrace();
> cachedConnector = null;
> }
> }
>
> return cachedConnector;
> }
>
> I hope this helps.
>
> Cheers
> /Eike
>
>
>
> Yannick Lizzi schrieb:
>> Hi all,
>>
>> I want to develop a CDO/Net4J client that connects to a CDO/Net4J
>> server. When the client application starts, it doesn't know the server
>> host and port.
>> So comparing to the CDO examples, I have to customize the
>> ActiveSocketConnector programmatically (not via Spring) by setting
>> host and port, while the CDO client starts.
>> How can I do this?
>>
>> I tried to set host and port before the resourceManager.start() by the
>> following code:
>> ActiveSocketConnector conn = (ActiveSocketConnector)
>> resourceManager.getChannel().getConnector();
>> conn.setHost(host);
>> conn.setPort(port);
>> The problem is that the connector have already started to connect with
>> the information taken from client.properties.
>>
>> I also tried to comment the connector bean in client.xml and create it
>> programmatically with the following code:
>> ActiveSocketConnectorImpl connector = new ActiveSocketConnectorImpl();
>> connector.setHost(host);
>> connector.setPort(port);
>> connector.setProtocolManager(clientContainer.getBean("protocolManager "));
>> connector.setSelectorManager(clientContainer.getBean("selectorManager "));
>> connector.setBufferPool(clientContainer.getBean("bufferPool "));
>> resourceManager.setConnector(connector);
>>
>> But in this case, I get a NoControlProtocolException when creating the
>> resource.
>>
>> So what's the right way?
>>
>> Thanks
>>
>> Yannick Lizzi
Previous Topic:OCL Query Plugins Required
Next Topic:Conat download Validation SDK 1.0.1
Goto Forum:
  


Current Time: Fri Sep 27 04:00:58 GMT 2024

Powered by FUDForum. Page generated in 0.03723 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top