Make sure PCEPMessageHeader is threadsafe
[bgpcep.git] / pcep / impl / src / main / java / org / opendaylight / protocol / pcep / impl / PCEPSessionFactoryImpl.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.protocol.pcep.impl;
9
10 import io.netty.channel.Channel;
11
12 import java.util.Timer;
13
14 import org.opendaylight.protocol.framework.ProtocolConnection;
15 import org.opendaylight.protocol.framework.ProtocolSessionFactory;
16 import org.opendaylight.protocol.framework.SessionParent;
17 import org.opendaylight.protocol.pcep.PCEPConnection;
18
19 public class PCEPSessionFactoryImpl implements ProtocolSessionFactory<PCEPSessionImpl> {
20
21         private final int maxUnknownMessages;
22
23         public PCEPSessionFactoryImpl(final int maxUnknownMessages) {
24                 this.maxUnknownMessages = maxUnknownMessages;
25         }
26
27         @Override
28         public PCEPSessionImpl getProtocolSession(final SessionParent parent, final Timer timer, final ProtocolConnection connection,
29                         final int sessionId, final Channel channel) {
30                 return new PCEPSessionImpl(parent, timer, (PCEPConnection) connection, new PCEPMessageFactory(), this.maxUnknownMessages, sessionId, channel);
31         }
32 }