| /* |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the |
| * "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, |
| * software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| * KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations |
| * under the License. |
| */ |
| |
| package org.netbeans.modules.j2ee.ejbjar; |
| |
| import java.util.HashMap; |
| import org.netbeans.modules.j2ee.api.ejbjar.*; |
| import org.netbeans.modules.j2ee.spi.ejbjar.*; |
| import org.openide.filesystems.FileObject; |
| |
| /** A dummy provider that things that any *.bar file belongs to its car module. |
| * |
| * @author Pavel Buzek |
| * @author Lukas Jungmann |
| */ |
| @org.openide.util.lookup.ServiceProvider(service=org.netbeans.modules.j2ee.spi.ejbjar.CarProvider.class) |
| public class CustomProviderCar implements CarProvider { |
| |
| private HashMap cache = new HashMap (); |
| |
| public CustomProviderCar () { |
| } |
| |
| public Car findCar (FileObject file) { |
| if (file.getExt ().equals ("bar")) { |
| Car em = (Car) cache.get (file.getParent ()); |
| if (em == null) { |
| em = CarFactory.createCar (new EM (file.getParent (), EjbProjectConstants.J2EE_14_LEVEL)); |
| cache.put (file.getParent (), em); |
| } |
| return em; |
| } |
| return null; |
| } |
| |
| private class EM implements CarImplementation { |
| FileObject root; |
| String ver; |
| |
| public EM (FileObject root, String ver) { |
| this.root = root; |
| this.ver = ver; |
| } |
| |
| public String getJ2eePlatformVersion () { |
| return ver; |
| } |
| |
| public FileObject getDeploymentDescriptor () { |
| return root.getFileObject ("conf/application-client.xml"); |
| } |
| |
| public FileObject getMetaInf () { |
| return null; |
| } |
| |
| public FileObject[] getJavaSources() { |
| return null; |
| } |
| } |
| } |