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 */
017 package org.apache.camel.pojo;
018
019 import java.util.HashMap;
020
021 import org.apache.camel.CamelContext;
022 import org.apache.camel.Component;
023
024 /**
025 * Represents the component that manages {@link PojoEndpoint}. It holds the
026 * list of named pojos that queue endpoints reference.
027 *
028 * @version $Revision: 519973 $
029 */
030 public class PojoComponent implements Component<PojoExchange> {
031
032 private final HashMap<String, Object> registry = new HashMap<String, Object>();
033 private final HashMap<String, PojoEndpoint> activatedEndpoints = new HashMap<String, PojoEndpoint>();
034
035 private CamelContext container;
036
037 public void registerPojo(String uri, Object pojo) {
038 registry.put(uri, pojo);
039 }
040 public Object lookupRegisteredPojo(String uri) {
041 return registry.get(uri);
042 }
043
044 public void registerActivation(String uri, PojoEndpoint endpoint) {
045 activatedEndpoints.put(uri, endpoint);
046 }
047 public void unregisterActivation(String uri) {
048 activatedEndpoints.remove(uri);
049 }
050 public PojoEndpoint lookupActivation(String uri) {
051 return activatedEndpoints.get(uri);
052 }
053
054
055 public void setContext(CamelContext container) {
056 this.container = container;
057 }
058 public CamelContext getContainer() {
059 return container;
060 }
061
062 }