001 /**
002 *
003 * Licensed to the Apache Software Foundation (ASF) under one or more
004 * contributor license agreements. See the NOTICE file distributed with
005 * this work for additional information regarding copyright ownership.
006 * The ASF licenses this file to You under the Apache License, Version 2.0
007 * (the "License"); you may not use this file except in compliance with
008 * the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018 package org.apache.camel.component.jpa;
019
020 import org.apache.camel.CamelContext;
021 import org.apache.camel.Component;
022 import org.apache.camel.Endpoint;
023 import org.apache.camel.Exchange;
024 import org.apache.camel.impl.DefaultComponent;
025 import org.apache.camel.util.IntrospectionSupport;
026 import org.apache.camel.util.ObjectHelper;
027
028 import javax.persistence.EntityManagerFactory;
029 import java.util.Map;
030
031 /**
032 * A JPA Component
033 *
034 * @version $Revision: 533794 $
035 */
036 public class JpaComponent extends DefaultComponent<Exchange> {
037 private EntityManagerFactory entityManagerFactory;
038
039 public Component resolveComponent(CamelContext container, String uri) throws Exception {
040 return null;
041 }
042
043 // Properties
044 //-------------------------------------------------------------------------
045 public EntityManagerFactory getEntityManagerFactory() {
046 return entityManagerFactory;
047 }
048
049 public void setEntityManagerFactory(EntityManagerFactory entityManagerFactory) {
050 this.entityManagerFactory = entityManagerFactory;
051 }
052
053 // Implementation methods
054 //-------------------------------------------------------------------------
055
056 @Override
057 protected Endpoint<Exchange> createEndpoint(String uri, String path, Map options) throws Exception {
058 JpaEndpoint endpoint = new JpaEndpoint(uri, this);
059
060 // lets interpret the next string as a class
061 if (path != null) {
062 Class<?> type = ObjectHelper.loadClass(path);
063 if (type != null) {
064 endpoint.setEntityType(type);
065 }
066 }
067 return endpoint;
068 }
069 }