001/** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.activemq.shiro; 018 019import org.apache.activemq.broker.ConnectionContext; 020import org.apache.activemq.command.ConnectionInfo; 021import org.apache.shiro.env.Environment; 022 023/** 024 * A reference (handle) to a client's {@link ConnectionContext} and {@link ConnectionInfo} as well as the Shiro 025 * {@link Environment}. 026 * <p/> 027 * This implementation primarily exists as a <a href="http://sourcemaking.com/refactoring/introduce-parameter-object"> 028 * Parameter Object Design Pattern</a> implementation to eliminate long parameter lists, but provides additional 029 * benefits, such as immutability and non-null guarantees, and possibility for future data without forcing method 030 * signature changes. 031 * 032 * @since 5.10.0 033 */ 034public class ConnectionReference { 035 036 private final ConnectionContext connectionContext; 037 private final ConnectionInfo connectionInfo; 038 private final Environment environment; 039 040 public ConnectionReference(ConnectionContext connCtx, ConnectionInfo connInfo, Environment environment) { 041 if (connCtx == null) { 042 throw new IllegalArgumentException("ConnectionContext argument cannot be null."); 043 } 044 if (connInfo == null) { 045 throw new IllegalArgumentException("ConnectionInfo argument cannot be null."); 046 } 047 if (environment == null) { 048 throw new IllegalArgumentException("Environment argument cannot be null."); 049 } 050 this.connectionContext = connCtx; 051 this.connectionInfo = connInfo; 052 this.environment = environment; 053 } 054 055 public ConnectionContext getConnectionContext() { 056 return connectionContext; 057 } 058 059 public ConnectionInfo getConnectionInfo() { 060 return connectionInfo; 061 } 062 063 public Environment getEnvironment() { 064 return environment; 065 } 066}