The new pervasive and context-aware computing models have resulted in the development of modern environments which are responsive to the changing needs of the people who live, work or socialise in them. These are called smart envirnments and they employ high degree of intelligence to consume and process information in order to provide services to users in accordance with their current needs. To achieve this level of intelligence, such environments collect, store, represent and interpret a vast amount of information which describes the current context of their users. Since context-aware systems differ in the way they interact with users and interpret the context of their entities and the actions they need to take, each individual system is developed in its own way with no common architecture. This fact makes the development of every context aware system a challenge. To address this issue, a new and generic framework has been developed which is based on the Pipe-and-Filter software architectural style, and can be applied to many systems. This framework uses a number of independent components that represent the usual functions of any context-aware system. These components can be configured in different arrangements to suit the various systems' requirements. The framework and architecture use a model to represent raw context information as a function of context primitives, referred to as Who, When, Where, What and How (4W1H). Historical context information is also defined and added to the model to predict some actions in the system. The framework uses XML code to represent the model and describes the sequence in which context information is being processed by the architecture's components (or filters). Moreover, a mechanism for describing interpretation rules for the purpose of context reasoning is proposed and implemented. A set of guidelines is provided for both the deployment and rule languages to help application developers in constructing and customising their own systems using various components of the new framework. To test and demonstrate the functionality of the generic architecture, a smart classroom environment has been adopted as a case study. An evaluation of the new framework has also been conducted using two methods: quantitative and case study driven evaluation. The quantitative method used information obtained from reviewing the literature which is then analysed and compared with the new framework in order to verify the completeness of the framework's components for different xiisituations. On the other hand, in the case study method the new framework has been applied in the implementation of different scenarios of well known systems. This method is used for verifying the applicability and generic nature of the framework. As an outcome, the framework is proven to be extensible with high degree of reusability and adaptability, and can be used to develop various context-aware systems.