[ 
https://issues.apache.org/jira/browse/OPENEJB-1023?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Alexandr Ryabukhin resolved OPENEJB-1023.
-----------------------------------------

    Resolution: Later

Replace source code org.apache.openejb.server.ejbd.EJBServer on text below.


/**
 * 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.
 */
package org.apache.openejb.server.ejbd;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Properties;

import org.apache.openejb.server.ServiceException;
import org.apache.openejb.core.ServerFederation;
import org.apache.openejb.ProxyInfo;

import javax.ejb.EJBMetaData;
import javax.ejb.Handle;
import javax.ejb.HomeHandle;
import javax.ejb.EJBObject;
import javax.ejb.EJBHome;

public class EjbServer implements org.apache.openejb.server.ServerService, 
org.apache.openejb.spi.ApplicationServer {

    EjbDaemon server;
    
    public void init(Properties props) throws Exception {
        server = EjbDaemon.getEjbDaemon();
        server.init(props);
    }

    public void start() throws ServiceException {
    }

    public void stop() throws ServiceException {
    }

    public String getName() {
        return "ejbd";
    }

    public int getPort() {
        return 0;
    }

    public void service(Socket socket) throws ServiceException, IOException {   
                CallContext context = CallContext.getCallContext();
                context.set(ClientAddress.class, new ClientAddress(socket));
                
        ServerFederation.setApplicationServer(server);
        server.service(socket);
    }

    public void service(InputStream inputStream, OutputStream outputStream) 
throws ServiceException, IOException {
        ServerFederation.setApplicationServer(server);
        server.service(inputStream, outputStream);
    }

    public String getIP() {
        return "";
    }

    public EJBMetaData getEJBMetaData(ProxyInfo info) {
        return server.getEJBMetaData(info);
    }

    public Handle getHandle(ProxyInfo info) {
        return server.getHandle(info);
    }

    public HomeHandle getHomeHandle(ProxyInfo info) {
        return server.getHomeHandle(info);
    }

    public EJBObject getEJBObject(ProxyInfo info) {
        return server.getEJBObject(info);
    }

    public Object getBusinessObject(ProxyInfo info) {
        return server.getBusinessObject(info);   
    }

    public EJBHome getEJBHome(ProxyInfo info) {
        return server.getEJBHome(info);
    }
    
    
  /**
     * Client IP-address and port
     * @author ryabukhin-av
     *
     */
    public class ClientAddress{
        private byte[] address;
        private int port;
        
                public ClientAddress(Socket socket){
                InetAddress ia = socket.getInetAddress();               
                address = ia == null ? null : ia.getAddress();
                port = socket.getPort();
        }
        
                
        public InetAddress getInetAddress(){
                try {
                                return InetAddress.getByAddress(address);
                        } catch (UnknownHostException e) {
                                return null;
                        }
        }
        
        public int getPort(){
                return port;
        }
        
    };
}


> Storing IP address and port of EJB-method caller in CallContext
> ---------------------------------------------------------------
>
>                 Key: OPENEJB-1023
>                 URL: https://issues.apache.org/jira/browse/OPENEJB-1023
>             Project: OpenEJB
>          Issue Type: Improvement
>          Components: server
>    Affects Versions: 3.1
>            Reporter: Alexandr Ryabukhin
>             Fix For: 3.1
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> Modify org.apache.openejb.server.ejbd.EJBServer for storing EJB-client IP 
> address and port in CallSession.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to