Issue Details (XML | Word | Printable)

Key: OPENEJB-1023
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Later
Priority: Major Major
Assignee: Unassigned
Reporter: Alexandr Ryabukhin
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
OpenEJB

Storing IP address and port of EJB-method caller in CallContext

Created: 29/Apr/09 06:31 PM   Updated: 29/Apr/09 06:36 PM
Return to search
Component/s: server
Affects Version/s: 3.1
Fix Version/s: 3.1

Time Tracking:
Original Estimate: 168h
Original Estimate - 168h
Remaining Estimate: 168h
Remaining Estimate - 168h
Time Spent: Not Specified
Remaining Estimate - 168h

Resolution Date: 29/Apr/09 06:36 PM


 Description  « Hide
Modify org.apache.openejb.server.ejbd.EJBServer for storing EJB-client IP address and port in CallSession.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Alexandr Ryabukhin added a comment - 29/Apr/09 06:36 PM
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;
     }
    
    };
}