blob: 4d560b172ed3e79e9459f76a5cc8610e078e0190 [file] [log] [blame]
## Copyright 2007-2008 Cisco Systems Inc.
##
## 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.
// This file automatically generated by:
// $version
// $now
// This file is automatically created and should not be edited!
#set($i = $intf.name())
package $intf.parent().name();
import org.apache.etch.bindings.java.support.DeliveryService;
import org.apache.etch.bindings.java.support.Pool;
#if($helper.isServer($mc) || $helper.isBoth($mc))
import org.apache.etch.bindings.java.support.ServerFactory;
import org.apache.etch.bindings.java.msg.ValueFactory;
import org.apache.etch.bindings.java.support.DefaultServerFactory;
#end
import org.apache.etch.util.core.io.Transport;
import org.apache.etch.bindings.java.support.TransportFactory;
import org.apache.etch.bindings.java.support.TransportHelper;
import org.apache.etch.bindings.java.transport.DefaultDeliveryService;
import org.apache.etch.bindings.java.transport.MailboxManager;
import org.apache.etch.bindings.java.transport.PlainMailboxManager;
import org.apache.etch.bindings.java.transport.TransportMessage;
import org.apache.etch.util.Resources;
import org.apache.etch.util.URL;
/**
* Transport helper for ${i}. All methods are static.
*/
abstract public class ${i}Helper extends TransportHelper
{
#if($helper.isServer($mc) || $helper.isBoth($mc))
/**
* Constructs a new server session listener per specifications in uri and
* resources. This listener will accept requests from clients for new server
* sessions.
*
* @param uri contains specifications for the server session listener and
* for the server session transport stack.
*
* @param resources additional resources to aid in constructing new server
* sessions.
*
* @param implFactory factory used to construct a new instance implementing
* ${i}Server. The new instance will receive and process messages from
* the client session.
*
* @return a server session listener.
*
* @throws Exception
*/
public static ServerFactory newListener( final String uri,
final Resources resources, final ${i}ServerFactory implFactory )
throws Exception
{
final Resources res = initResources( resources );
final Transport<ServerFactory> listener = TransportFactory.getListener( uri, res );
return new DefaultServerFactory( listener, implFactory )
{
public void newServer( TransportMessage t, String uri, Resources r )
throws Exception
{
ValueFactory vf = (ValueFactory) r.get( Transport.VALUE_FACTORY );
MailboxManager x = new PlainMailboxManager( t, uri, r );
DeliveryService d = new DefaultDeliveryService( x, uri, r );
Remote${i}Client client = new Remote${i}Client( d, vf );
${i}Server server = implFactory.new${i}Server( client );
Pool qp = (Pool) r.get( QUEUED_POOL );
Pool fp = (Pool) r.get( FREE_POOL );
new Stub${i}Server( d, server, qp, fp );
client._start();
}
public ValueFactory newValueFactory( String uri )
{
return new ValueFactory${i}( uri );
}
@Override
public String toString()
{
return "${i}Helper.ServerFactory/" + listener;
}
};
}
/**
* Factory used by
* {@link ${i}Helper#newListener(String, Resources, ${i}ServerFactory)}
* to construct a new instance implementing {@link ${i}Server}. The new
* instance will receive and process messages from the client session.
*/
public interface ${i}ServerFactory
{
/**
* Constructs a new instance implementing ${i}Server. The new
* instance will receive and process messages from the client session.
*
* @param client an instance of Remote${i}Client which may be used to
* send messages to the client session.
* @return a new instance implementing ${i}Server (typically
* Impl${i}Server).
* @throws Exception
*/
public ${i}Server new${i}Server( Remote${i}Client client )
throws Exception;
}
#end
#if($helper.isClient($mc) || $helper.isBoth($mc))
/**
* Constructs a new client session per specifications in uri and resources.
*
* @param uri contains specifications for the client session transport
* stack.
*
* @param resources additional resources to aid in constructing new client
* sessions.
*
* @param implFactory factory used to construct a new instance implementing
* ${i}Client. The new instance will receive and process messages from
* the server session.
*
* @return an instance of Remote${i}Server initialized by uri and
* resources which may be used to send messages to the server session.
*
* @throws Exception
*/
public static Remote${i}Server newServer( String uri,
Resources resources, ${i}ClientFactory implFactory )
throws Exception
{
final Resources res = initResources( resources );
final ValueFactory${i} vf = new ValueFactory${i}( uri );
res.put( Transport.VALUE_FACTORY, vf );
URL u = new URL( uri );
TransportMessage m = TransportFactory.getTransport( uri, res );
MailboxManager r = new PlainMailboxManager( m, u, resources );
DeliveryService d = new DefaultDeliveryService( r, u, resources );
Remote${i}Server server = new Remote${i}Server( d, vf );
${i}Client client = implFactory.new${i}Client( server );
Pool qp = (Pool) res.get( QUEUED_POOL );
Pool fp = (Pool) res.get( FREE_POOL );
new Stub${i}Client( d, client, qp, fp );
return server;
}
/**
* Factory used by
* {@link ${i}Helper#newServer(String, Resources, ${i}ClientFactory)}
* to construct a new instance implementing {@link ${i}Client}. The new
* instance will receive and process messages from the server session.
*/
public interface ${i}ClientFactory
{
/**
* Constructs a new instance implementing ${i}Client. The new
* instance will receive and process messages from the server session.
*
* @param server an instance of Remote${i}Server which may be used to
* send messages to the server session.
* @return a new instance implementing ${i}Client (typically
* Impl${i}Client).
* @throws Exception
*/
public ${i}Client new${i}Client( Remote${i}Server server )
throws Exception;
}
#end
}