| /* |
| Licensed to the Apache Software Foundation (ASF) under one |
| or more contributor license agreements. See the NOTICE file |
| distributed with this work for additional information |
| regarding copyright ownership. The ASF licenses this file |
| to you 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: |
| // Apache Etch 1.1.0-incubating (LOCAL-0) / go 1.1.0-incubating (LOCAL-0) |
| // Thu Nov 18 15:39:28 CET 2010 |
| // This file is automatically created and should not be edited! |
| |
| package org_apache_etch_examples_helloworld |
| |
| import "etch" |
| |
| |
| type HelloWorldServerFactory struct { |
| session etch.Session |
| transport etch.Transport |
| } |
| |
| func NewHelloWorldServerFactory(transport etch.Transport) *HelloWorldServerFactory { |
| val := &HelloWorldServerFactory{nil, transport} |
| return val |
| } |
| |
| func NewListener(addr string) etch.Transport{ |
| tl := etch.NewTcpListener(addr) |
| dsl := etch.NewDefaultSessionListener(tl) |
| tl.SetSession(dsl) |
| sf := NewHelloWorldServerFactory(dsl) |
| dsl.SetSession(sf) |
| return sf |
| } |
| |
| func (dsf *HelloWorldServerFactory) NewServer(connection *etch.TcpConnection) { |
| ptzr := etch.NewPacketizer(connection, 10*1024) |
| connection.SetSession(ptzr) |
| dvf := NewValueFactoryHelloWorld() |
| msgzr := etch.NewMessagizer(dvf, ptzr) |
| ptzr.SetSession(msgzr) |
| mbm := etch.NewPlainMailboxManager(nil, msgzr) |
| msgzr.SetSession(mbm) |
| dsvc := etch.NewDefaultDeliveryService(mbm, nil) |
| mbm.SetSession(dsvc) |
| impl := new(ImplHelloWorldServer) |
| |
| stub := etch.NewEtchStub(dsvc, impl) |
| dsvc.SetSession(stub) |
| |
| impl.TheClient = NewRemoteHelloWorldClient(dsvc, dvf) |
| SetStubHelpers_StubHelloWorldServer(dvf) |
| |
| dsvc.TransportControl(etch.START, 4000) |
| } |
| |
| |
| func (dsf *HelloWorldServerFactory) SessionQuery(obj interface{}) interface{} { |
| return nil |
| } |
| |
| func (dsf *HelloWorldServerFactory) SessionControl(ctrl interface{}, value interface{}) interface{} { |
| return nil |
| } |
| |
| func (dsf *HelloWorldServerFactory) SessionNotify(obj interface{}) { |
| |
| } |
| |
| func (dsf *HelloWorldServerFactory) GetSession() etch.Session { |
| return nil |
| } |
| |
| func (dsf *HelloWorldServerFactory) SetSession(sess etch.Session) { |
| |
| } |
| |
| func (dsf *HelloWorldServerFactory) TransportQuery(obj interface{}) interface{} { |
| return nil |
| } |
| |
| func (dsf *HelloWorldServerFactory) TransportControl(ctrl interface{}, value interface{}) { |
| dsf.transport.TransportControl(ctrl, value) |
| } |
| |
| func (dsf *HelloWorldServerFactory) TransportNotify(value interface{}) { |
| |
| } |
| |
| func NewRemoteServer(addr string) *RemoteHelloWorldServer{ |
| tcpClientConn := etch.NewTcpConnection(addr, false, nil, nil) |
| cdsvc, vf := buildStack(tcpClientConn) |
| return NewRemoteHelloWorldServer(cdsvc, vf) |
| } |
| |
| func buildStack(conn *etch.TcpConnection) (etch.DeliveryService, etch.ValueFactory) { |
| ptzr := etch.NewPacketizer(conn, 10*1024) |
| conn.SetSession(ptzr) |
| dvf := NewValueFactoryHelloWorld() |
| msgzr := etch.NewMessagizer(dvf, ptzr) |
| ptzr.SetSession(msgzr) |
| mbm := etch.NewPlainMailboxManager(nil, msgzr) |
| msgzr.SetSession(mbm) |
| dsvc := etch.NewDefaultDeliveryService(mbm, nil) |
| mbm.SetSession(dsvc) |
| stub := etch.NewEtchStub(dsvc, new(ImplHelloWorldClient)) |
| dsvc.SetSession(stub) |
| |
| SetStubHelpers_StubHelloWorldClient(dvf) |
| return dsvc, dvf |
| } |