Modified: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/OpenEjbXmlConverter.java URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/OpenEjbXmlConverter.java?rev=605823&r1=605822&r2=605823&view=diff ============================================================================== --- openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/OpenEjbXmlConverter.java (original) +++ openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/OpenEjbXmlConverter.java Wed Dec 19 23:49:19 2007 @@ -1,182 +1,384 @@ -/* - * 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.apache.openejb.helper.annotation; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import javax.ejb.TransactionAttributeType; -import javax.ejb.TransactionManagementType; - -import org.apache.openejb.jee.ApplicationException; -import org.apache.openejb.jee.AssemblyDescriptor; -import org.apache.openejb.jee.EjbJar; -import org.apache.openejb.jee.EnterpriseBean; -import org.apache.openejb.jee.EntityBean; -import org.apache.openejb.jee.JaxbJavaee; -import org.apache.openejb.jee.MessageDrivenBean; -import org.apache.openejb.jee.MethodTransaction; -import org.apache.openejb.jee.SessionBean; -import org.apache.openejb.jee.SessionType; -import org.apache.openejb.jee.StatefulBean; -import org.apache.openejb.jee.StatelessBean; -import org.apache.openejb.jee.TransactionType; -import org.eclipse.core.resources.IProject; -import org.xml.sax.InputSource; - -/** - * Scans an openejb-jar.xml file using a SAX parser, and adds annotations - * to source based on the XML. - * - * Depends on an implementation of IJavaProjectAnnotationFacade - * - */ -public class OpenEjbXmlConverter { - - public static final String CLS_TRANSACTION_ATTRIBUTE = "javax.ejb.TransactionAttribute"; - public static final String CLS_APPLICATION_EXCEPTION = "javax.ejb.ApplicationException"; - public static final String CLS_STATEFUL = "javax.ejb.Stateful"; - public static final String CLS_STATELESS = "javax.ejb.Stateless"; - public static final String CLS_MESSAGE_DRIVEN = "javax.ejb.MessageDriven"; - public static final String STATELESS_CLASS = CLS_STATELESS; - protected IJavaProjectAnnotationFacade annotationHelper; - - - /** - * Constucts a new converter - * @param annotationHelper Annotation Facade to use for adding annotations - */ - public OpenEjbXmlConverter(IJavaProjectAnnotationFacade annotationHelper) { - this.annotationHelper = annotationHelper; - } - - /** - * Constructs a new converter - uses the default implementation of - * IJavaProjectAnnotationFacade - JavaProjectAnnotationFacade - * @param project An eclipse Java project - */ - public OpenEjbXmlConverter(IProject project) { - this(new JavaProjectAnnotationFacade(project)); - } - - /** - * Parses the XML - * @param source An input source to the content of ejb-jar.xml - * @return Whether or not the parsing was successful - */ - public boolean convert(InputSource source) { - try { - EjbJar ejbJar = (EjbJar) JaxbJavaee.unmarshal(EjbJar.class, source.getByteStream()); - - processEnterpriseBeans(ejbJar); - processApplicationExceptions(ejbJar); - - return true; - } catch (Exception e) { - return false; - } - } - - private void processApplicationExceptions(EjbJar ejbJar) { - List<ApplicationException> exceptionList = ejbJar.getAssemblyDescriptor().getApplicationException(); - Iterator<ApplicationException> iterator = exceptionList.iterator(); - - while (iterator.hasNext()) { - ApplicationException element = (ApplicationException) iterator.next(); - String exceptionClass = element.getExceptionClass(); - - annotationHelper.addClassAnnotation(exceptionClass, CLS_APPLICATION_EXCEPTION); - } - } - - private void processEnterpriseBeans(EjbJar ejbJar) { - EnterpriseBean[] enterpriseBeans = ejbJar.getEnterpriseBeans(); - Iterator<EnterpriseBean> iterator = Arrays.asList(enterpriseBeans).iterator(); - while (iterator.hasNext()) { - EnterpriseBean bean = (EnterpriseBean) iterator.next(); - if (bean instanceof SessionBean) { - SessionBean sessionBean = (SessionBean) bean; - processSessionBean(sessionBean); - } else if (bean instanceof EntityBean) { - EntityBean entityBean = (EntityBean) bean; - processEntityBean(entityBean); - } else if (bean instanceof MessageDrivenBean) { - MessageDrivenBean messageDriven = (MessageDrivenBean) bean; - processMessageDrivenBean(messageDriven); - } - - processTransactionManagement(bean, ejbJar.getAssemblyDescriptor()); - } - - } - - private void processTransactionManagement(EnterpriseBean bean, AssemblyDescriptor descriptor) { - TransactionType transactionType = bean.getTransactionType(); - - if (transactionType != null && (! TransactionType.CONTAINER.equals(transactionType))) { - Map<String,Object> props = new HashMap<String, Object>(); - props.put("value", TransactionManagementType.BEAN); - - annotationHelper.addClassAnnotation(bean.getEjbClass(), "javax.ejb.TransactionManagement", props); - } - - Map<String, List<MethodTransaction>> methodTransactions = descriptor.getMethodTransactions(bean.getEjbName()); - if (methodTransactions.containsKey("*")) { - List<MethodTransaction> defaultTransactions = methodTransactions.get("*"); - MethodTransaction defaultTransaction = defaultTransactions.get(0); - - Map<String, Object> props = new HashMap<String, Object>(); - props.put("value", TransactionAttributeType.valueOf(defaultTransaction.getAttribute().name())); - annotationHelper.addClassAnnotation(bean.getEjbClass(), CLS_TRANSACTION_ATTRIBUTE, props); - } - - Iterator<String> iterator = methodTransactions.keySet().iterator(); - while (iterator.hasNext()) { - String methodName = (String) iterator.next(); - if ("*".equals(methodName)) { - continue; - } - - List<MethodTransaction> transactions = methodTransactions.get(methodName); - MethodTransaction methodTransaction = transactions.get(0); - - Map<String, Object> props = new HashMap<String, Object>(); - props.put("value", TransactionAttributeType.valueOf(methodTransaction.getAttribute().name())); - annotationHelper.addMethodAnnotation(bean.getEjbClass(), methodName, CLS_TRANSACTION_ATTRIBUTE, props); - } - } - - private void processMessageDrivenBean(MessageDrivenBean entityBean) { - annotationHelper.addClassAnnotation(entityBean.getEjbClass(), CLS_MESSAGE_DRIVEN); - } - - private void processEntityBean(EntityBean entityBean) { - } - - private void processSessionBean(SessionBean sessionBean) { - String ejbClass = sessionBean.getEjbClass(); - if (sessionBean instanceof StatelessBean || sessionBean.getSessionType() == SessionType.STATELESS) { - annotationHelper.addClassAnnotation(ejbClass, CLS_STATELESS); - } else if (sessionBean instanceof StatefulBean || sessionBean.getSessionType() == SessionType.STATELESS) { - annotationHelper.addClassAnnotation(ejbClass, CLS_STATEFUL); - } - } -} +/* + * 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.apache.openejb.helper.annotation; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.annotation.security.DeclareRoles; +import javax.annotation.security.DenyAll; +import javax.annotation.security.PermitAll; +import javax.annotation.security.RolesAllowed; +import javax.annotation.security.RunAs; +import javax.ejb.MessageDriven; +import javax.ejb.Remote; +import javax.ejb.RemoteHome; +import javax.ejb.Stateful; +import javax.ejb.Stateless; +import javax.ejb.TransactionAttribute; +import javax.ejb.TransactionAttributeType; +import javax.ejb.TransactionManagement; +import javax.ejb.TransactionManagementType; +import javax.interceptor.ExcludeClassInterceptors; +import javax.interceptor.ExcludeDefaultInterceptors; +import javax.interceptor.Interceptors; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Unmarshaller; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import javax.xml.transform.sax.SAXSource; + +import org.apache.openejb.jee.ActivationConfig; +import org.apache.openejb.jee.ActivationConfigProperty; +import org.apache.openejb.jee.ApplicationException; +import org.apache.openejb.jee.AssemblyDescriptor; +import org.apache.openejb.jee.EjbJar; +import org.apache.openejb.jee.EnterpriseBean; +import org.apache.openejb.jee.EntityBean; +import org.apache.openejb.jee.InterceptorBinding; +import org.apache.openejb.jee.JaxbJavaee; +import org.apache.openejb.jee.MessageDrivenBean; +import org.apache.openejb.jee.Method; +import org.apache.openejb.jee.MethodParams; +import org.apache.openejb.jee.MethodPermission; +import org.apache.openejb.jee.MethodTransaction; +import org.apache.openejb.jee.NamedMethod; +import org.apache.openejb.jee.RemoteBean; +import org.apache.openejb.jee.SecurityRoleRef; +import org.apache.openejb.jee.SessionBean; +import org.apache.openejb.jee.SessionType; +import org.apache.openejb.jee.StatefulBean; +import org.apache.openejb.jee.StatelessBean; +import org.apache.openejb.jee.TransactionType; +import org.eclipse.core.resources.IProject; +import org.xml.sax.InputSource; + +/** + * Scans an ejb-jar.xml file using a JAXB parser, and adds annotations + * to source based on the XML. + * + * Depends on an implementation of IJavaProjectAnnotationFacade + * + */ +public class OpenEjbXmlConverter { + + public static final String CLS_TRANSACTION_ATTRIBUTE = "javax.ejb.TransactionAttribute"; + public static final String CLS_APPLICATION_EXCEPTION = "javax.ejb.ApplicationException"; + public static final String CLS_STATEFUL = "javax.ejb.Stateful"; + public static final String CLS_STATELESS = "javax.ejb.Stateless"; + public static final String CLS_MESSAGE_DRIVEN = "javax.ejb.MessageDriven"; + public static final String STATELESS_CLASS = CLS_STATELESS; + protected IJavaProjectAnnotationFacade annotationHelper; + + + /** + * Constucts a new converter + * @param annotationHelper Annotation Facade to use for adding annotations + */ + public OpenEjbXmlConverter(IJavaProjectAnnotationFacade annotationHelper) { + this.annotationHelper = annotationHelper; + } + + /** + * Constructs a new converter - uses the default implementation of + * IJavaProjectAnnotationFacade - JavaProjectAnnotationFacade + * @param project An eclipse Java project + */ + public OpenEjbXmlConverter(IProject project) { + this(new JavaProjectAnnotationFacade(project)); + } + + /** + * Parses the XML + * @param source An input source to the content of ejb-jar.xml + * @return Whether or not the parsing was successful + */ + public boolean convert(InputSource source) { + try { + EjbJar ejbJar = (EjbJar) JaxbJavaee.unmarshal(EjbJar.class, source.getByteStream()); + + processEnterpriseBeans(ejbJar); + processApplicationExceptions(ejbJar); + + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + private void processApplicationExceptions(EjbJar ejbJar) { + List<ApplicationException> exceptionList = ejbJar.getAssemblyDescriptor().getApplicationException(); + Iterator<ApplicationException> iterator = exceptionList.iterator(); + + while (iterator.hasNext()) { + ApplicationException element = (ApplicationException) iterator.next(); + String exceptionClass = element.getExceptionClass(); + + annotationHelper.addClassAnnotation(exceptionClass, javax.ejb.ApplicationException.class, null); + } + } + + private void processEnterpriseBeans(EjbJar ejbJar) { + EnterpriseBean[] enterpriseBeans = ejbJar.getEnterpriseBeans(); + Iterator<EnterpriseBean> iterator = Arrays.asList(enterpriseBeans).iterator(); + while (iterator.hasNext()) { + EnterpriseBean bean = (EnterpriseBean) iterator.next(); + if (bean instanceof SessionBean) { + SessionBean sessionBean = (SessionBean) bean; + processSessionBean(sessionBean); + } else if (bean instanceof EntityBean) { + EntityBean entityBean = (EntityBean) bean; + processEntityBean(entityBean); + } else if (bean instanceof MessageDrivenBean) { + MessageDrivenBean messageDriven = (MessageDrivenBean) bean; + processMessageDrivenBean(messageDriven); + } + + processTransactionManagement(bean, ejbJar.getAssemblyDescriptor()); + processBeanSecurityIdentity(bean); + processDeclaredRoles(bean); + processMethodPermissions(ejbJar); + } + + + + } + + /** + * Generates transaction management annotations for an Enterprise Bean + * @param bean The enterprise bean to generate annotations for + * @param descriptor The assembly descriptor + */ + public void processTransactionManagement(EnterpriseBean bean, AssemblyDescriptor descriptor) { + TransactionType transactionType = bean.getTransactionType(); + + if (transactionType != null && (! TransactionType.CONTAINER.equals(transactionType))) { + Map<String,Object> props = new HashMap<String, Object>(); + props.put("value", TransactionManagementType.BEAN); + + annotationHelper.addClassAnnotation(bean.getEjbClass(), TransactionManagement.class, props); + } + + Map<String, List<MethodTransaction>> methodTransactions = descriptor.getMethodTransactions(bean.getEjbName()); + if (methodTransactions.containsKey("*")) { + List<MethodTransaction> defaultTransactions = methodTransactions.get("*"); + MethodTransaction defaultTransaction = defaultTransactions.get(0); + + Map<String, Object> props = new HashMap<String, Object>(); + props.put("value", TransactionAttributeType.valueOf(defaultTransaction.getAttribute().name())); + annotationHelper.addClassAnnotation(bean.getEjbClass(), TransactionAttribute.class, props); + } + + Iterator<String> iterator = methodTransactions.keySet().iterator(); + while (iterator.hasNext()) { + String methodName = (String) iterator.next(); + if ("*".equals(methodName)) { + continue; + } + + List<MethodTransaction> transactions = methodTransactions.get(methodName); + MethodTransaction methodTransaction = transactions.get(0); + + Map<String, Object> props = new HashMap<String, Object>(); + props.put("value", TransactionAttributeType.valueOf(methodTransaction.getAttribute().name())); + + MethodParams methodParams = methodTransaction.getMethod().getMethodParams(); + String[] params = methodParams.getMethodParam().toArray(new String[0]); + annotationHelper.addMethodAnnotation(bean.getEjbClass(), methodName, params, TransactionAttribute.class, props); + } + } + + public void processMessageDrivenBean(MessageDrivenBean bean) { + Map<String, Object> props = new HashMap<String, Object>(); + + ActivationConfig activationConfig = bean.getActivationConfig(); + if (activationConfig != null) { + List<Map<String, Object>> activationConfigPropertiesList = new ArrayList<Map<String,Object>>(); + + List<ActivationConfigProperty> activationConfigProperties = activationConfig.getActivationConfigProperty(); + + for (ActivationConfigProperty activationConfigProperty : activationConfigProperties) { + HashMap<String, Object> configProps = new HashMap<String, Object>(); + configProps.put("propertyName", activationConfigProperty.getActivationConfigPropertyName()); + configProps.put("propertyValue", activationConfigProperty.getActivationConfigPropertyValue()); + + activationConfigPropertiesList.add(configProps); + } + + props.put("activationConfig", activationConfigPropertiesList.toArray(new HashMap[0])); + } + + annotationHelper.addClassAnnotation(bean.getEjbClass(), MessageDriven.class, props); + } + + private void processEntityBean(EntityBean entityBean) { + } + + public void processSessionBean(SessionBean sessionBean) { + String ejbClass = sessionBean.getEjbClass(); + if (sessionBean instanceof StatelessBean || sessionBean.getSessionType() == SessionType.STATELESS) { + annotationHelper.addClassAnnotation(ejbClass, Stateless.class, null); + } else if (sessionBean instanceof StatefulBean || sessionBean.getSessionType() == SessionType.STATELESS) { + annotationHelper.addClassAnnotation(ejbClass, Stateful.class, null); + } + + if (sessionBean instanceof RemoteBean) { + if (sessionBean.getRemote() != null && sessionBean.getRemote().length() > 0) { + annotationHelper.addClassAnnotation(sessionBean.getRemote(), Remote.class, null); + } + + if (sessionBean.getHome() != null && sessionBean.getHome().length() > 0) { + Map<String, Object> props = new HashMap<String, Object>(); + props.put("value", sessionBean.getHome()); + annotationHelper.addClassAnnotation(ejbClass, RemoteHome.class, props); + } + } + } + + public void processMethodPermissions(EjbJar ejbJar) { + AssemblyDescriptor descriptor = ejbJar.getAssemblyDescriptor(); + + List<MethodPermission> methodPermissions = descriptor.getMethodPermission(); + Iterator<MethodPermission> iterator = methodPermissions.iterator(); + + while (iterator.hasNext()) { + MethodPermission methodPermission = (MethodPermission) iterator.next(); + List<String> roles = methodPermission.getRoleName(); + + if (roles == null || roles.size() == 0) { + continue; + } + + String[] roleList = roles.toArray(new String[0]); + Map<String, Object> roleProps = new HashMap<String, Object>(); + roleProps.put("value", roleList); + + + List<Method> methods = methodPermission.getMethod(); + Iterator<Method> methodIter = methods.iterator(); + + while (methodIter.hasNext()) { + Method method = (Method) methodIter.next(); + EnterpriseBean enterpriseBean = ejbJar.getEnterpriseBean(method.getEjbName()); + + MethodParams methodParams = method.getMethodParams(); + String[] params = methodParams.getMethodParam().toArray(new String[0]); + + if ((! "*".equals(method.getMethodName())) && descriptor.getExcludeList().getMethod().contains(method)) { + annotationHelper.addMethodAnnotation(enterpriseBean.getEjbClass(), method.getMethodName(), params, DenyAll.class, null); + continue; + } + + if (methodPermission.getUnchecked()) { + if ("*".equals(method.getMethodName())) { + annotationHelper.addClassAnnotation(enterpriseBean.getEjbClass(), PermitAll.class, null); + } else { + annotationHelper.addMethodAnnotation(enterpriseBean.getEjbClass(), method.getMethodName(), params, PermitAll.class, null); + } + } else { + if ("*".equals(method.getMethodName())) { + annotationHelper.addClassAnnotation(enterpriseBean.getEjbClass(), RolesAllowed.class, roleProps); + } else { + annotationHelper.addMethodAnnotation(enterpriseBean.getEjbClass(), method.getMethodName(), params, RolesAllowed.class, roleProps); + } + } + } + } + } + + public void processBeanSecurityIdentity(EnterpriseBean bean) { + if (bean.getSecurityIdentity() == null) { + return; + } + + Map<String, Object> runAsProps = new HashMap<String, Object>(); + runAsProps.put("value", bean.getSecurityIdentity().getRunAs()); + + annotationHelper.addClassAnnotation(bean.getEjbClass(), RunAs.class, runAsProps); + } + + public void processDeclaredRoles(EnterpriseBean bean) { + if (! (bean instanceof RemoteBean)) { + return; + } + + RemoteBean remoteBean = (RemoteBean) bean; + List<SecurityRoleRef> securityRoleRefs = remoteBean.getSecurityRoleRef(); + + if (securityRoleRefs == null || securityRoleRefs.size() == 0) { + return; + } + + Map<String, Object> props = new HashMap<String, Object>(); + List<String> roleList = new ArrayList<String>(); + + for (SecurityRoleRef securityRoleRef : securityRoleRefs) { + roleList.add(securityRoleRef.getRoleName()); + } + + props.put("value", roleList.toArray(new String[0])); + annotationHelper.addClassAnnotation(bean.getEjbClass(), DeclareRoles.class, props); + } + + public void processInterceptors(EjbJar ejbJar) { + List<InterceptorBinding> interceptorBindings = ejbJar.getAssemblyDescriptor().getInterceptorBinding(); + + for (InterceptorBinding interceptorBinding : interceptorBindings) { + EnterpriseBean bean = ejbJar.getEnterpriseBean(interceptorBinding.getEjbName()); + + List<String> interceptorClasses = interceptorBinding.getInterceptorClass(); + + String[] classes = interceptorClasses.toArray(new String[0]); + + Map<String, Object> properties = new HashMap<String, Object>(); + properties.put("value", classes); + + if (interceptorBinding.getMethod() == null) { + if (interceptorBinding.getExcludeDefaultInterceptors()) { + annotationHelper.addClassAnnotation(bean.getEjbClass(), ExcludeDefaultInterceptors.class, properties); + } + + if (interceptorBinding.getExcludeClassInterceptors()) { + annotationHelper.addClassAnnotation(bean.getEjbClass(), ExcludeClassInterceptors.class, properties); + } + + annotationHelper.addClassAnnotation(bean.getEjbClass(), Interceptors.class, properties); + } else { + NamedMethod method = interceptorBinding.getMethod(); + String[] signature = method.getMethodParams().getMethodParam().toArray(new String[0]); + + if (interceptorBinding.getExcludeDefaultInterceptors()) { + annotationHelper.addMethodAnnotation(bean.getEjbClass(), method.getMethodName(), signature, ExcludeDefaultInterceptors.class, properties); + } + + if (interceptorBinding.getExcludeClassInterceptors()) { + annotationHelper.addMethodAnnotation(bean.getEjbClass(), method.getMethodName(), signature, ExcludeClassInterceptors.class, properties); + } + + annotationHelper.addMethodAnnotation(bean.getEjbClass(), method.getMethodName(), signature, Interceptors.class, properties); + } + } + } +}
Modified: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/wizards/EJBMigrationRefactoring.java URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/wizards/EJBMigrationRefactoring.java?rev=605823&r1=605822&r2=605823&view=diff ============================================================================== --- openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/wizards/EJBMigrationRefactoring.java (original) +++ openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/wizards/EJBMigrationRefactoring.java Wed Dec 19 23:49:19 2007 @@ -1,113 +1,115 @@ -/* - * 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.apache.openejb.helper.annotation.wizards; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; - -import org.apache.openejb.helper.annotation.JavaProjectAnnotationFacade; -import org.apache.openejb.helper.annotation.OpenEjbXmlConverter; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.ltk.core.refactoring.Change; -import org.eclipse.ltk.core.refactoring.Refactoring; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; -import org.eclipse.ltk.core.refactoring.RefactoringStatusEntry; -import org.xml.sax.InputSource; - -public class EJBMigrationRefactoring extends Refactoring { - - protected String ejbJarXmlFile; - protected String openEjbJarXmlFile; - protected IProject project; - - @Override - public RefactoringStatus checkFinalConditions(IProgressMonitor pm) - throws CoreException, OperationCanceledException { - - return new RefactoringStatus(); - } - - @Override - public RefactoringStatus checkInitialConditions(IProgressMonitor pm) - throws CoreException, OperationCanceledException { - - if (ejbJarXmlFile == null || ejbJarXmlFile.length() == 0) { - return RefactoringStatus.createErrorStatus("No ejb-jar.xml specified"); - } - - IFile file = project.getFile(ejbJarXmlFile); - if (! (file.exists())) { - return RefactoringStatus.createErrorStatus("Specified ejb-jar.xml does not exist"); - } - - return new RefactoringStatus(); - } - - @Override - public Change createChange(IProgressMonitor pm) throws CoreException, - OperationCanceledException { - - IFile file = project.getFile(ejbJarXmlFile); - if (! (file.exists())) { - return null; - } - - JavaProjectAnnotationFacade annotationFacade = new JavaProjectAnnotationFacade(project); - OpenEjbXmlConverter converter = new OpenEjbXmlConverter(annotationFacade); - converter.convert(new InputSource(file.getContents())); - - return annotationFacade.getChange(); - } - - @Override - public String getName() { - return "EJB 3.0 Annotation Migration Refactoring Wizard"; - } - - public String getEjbJarXmlFile() { - return ejbJarXmlFile; - } - - public void setEjbJarXmlFile(String ejbJarXmlFile) { - this.ejbJarXmlFile = ejbJarXmlFile; - } - - public String getOpenEjbJarXmlFile() { - return openEjbJarXmlFile; - } - - public void setOpenEjbJarXmlFile(String openEjbJarXmlFile) { - this.openEjbJarXmlFile = openEjbJarXmlFile; - } - - public IProject getProject() { - return project; - } - - public void setProject(IProject project) { - this.project = project; - } - - -} +/* + * 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.apache.openejb.helper.annotation.wizards; + +import org.apache.openejb.helper.annotation.JavaProjectAnnotationFacade; +import org.apache.openejb.helper.annotation.OpenEjbXmlConverter; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.ltk.core.refactoring.Change; +import org.eclipse.ltk.core.refactoring.Refactoring; +import org.eclipse.ltk.core.refactoring.RefactoringStatus; +import org.xml.sax.InputSource; + +public class EJBMigrationRefactoring extends Refactoring { + + protected String ejbJarXmlFile; + protected String openEjbJarXmlFile; + protected IProject project; + protected RefactoringStatus status = new RefactoringStatus(); + + @Override + public RefactoringStatus checkFinalConditions(IProgressMonitor pm) + + + throws CoreException, OperationCanceledException { + + status = new RefactoringStatus(); + + return status; + } + + @Override + public RefactoringStatus checkInitialConditions(IProgressMonitor pm) + throws CoreException, OperationCanceledException { + + if (ejbJarXmlFile == null || ejbJarXmlFile.length() == 0) { + return RefactoringStatus.createErrorStatus("No ejb-jar.xml specified"); + } + + IFile file = project.getFile(ejbJarXmlFile); + if (! (file.exists())) { + return RefactoringStatus.createErrorStatus("Specified ejb-jar.xml does not exist"); + } + + return new RefactoringStatus(); + } + + @Override + public Change createChange(IProgressMonitor pm) throws CoreException, + OperationCanceledException { + + IFile file = project.getFile(ejbJarXmlFile); + if (! (file.exists())) { + return null; + } + + JavaProjectAnnotationFacade annotationFacade = new JavaProjectAnnotationFacade(project); + OpenEjbXmlConverter converter = new OpenEjbXmlConverter(annotationFacade); + converter.convert(new InputSource(file.getContents())); + + String[] warnings = annotationFacade.getWarnings(); + for (String warning : warnings) { + status.addWarning(warning); + } + + return annotationFacade.getChange(); + } + + @Override + public String getName() { + return "EJB 3.0 Annotation Migration Refactoring Wizard"; + } + + public String getEjbJarXmlFile() { + return ejbJarXmlFile; + } + + public void setEjbJarXmlFile(String ejbJarXmlFile) { + this.ejbJarXmlFile = ejbJarXmlFile; + } + + public String getOpenEjbJarXmlFile() { + return openEjbJarXmlFile; + } + + public void setOpenEjbJarXmlFile(String openEjbJarXmlFile) { + this.openEjbJarXmlFile = openEjbJarXmlFile; + } + + public IProject getProject() { + return project; + } + + public void setProject(IProject project) { + this.project = project; + } +} Modified: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/wizards/EJBMigrationWizard.java URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/wizards/EJBMigrationWizard.java?rev=605823&r1=605822&r2=605823&view=diff ============================================================================== --- openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/wizards/EJBMigrationWizard.java (original) +++ openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/wizards/EJBMigrationWizard.java Wed Dec 19 23:49:19 2007 @@ -17,12 +17,14 @@ package org.apache.openejb.helper.annotation.wizards; -import org.eclipse.ltk.core.refactoring.Refactoring; import org.eclipse.ltk.ui.refactoring.RefactoringWizard; public class EJBMigrationWizard extends RefactoringWizard { - public EJBMigrationWizard(Refactoring refactoring, int flags) { + private final EJBMigrationRefactoring refactoring; + + public EJBMigrationWizard(EJBMigrationRefactoring refactoring, int flags) { super(refactoring, flags); + this.refactoring = refactoring; } protected EJBJarSelectionPage ejbJarSelectionPage; @@ -30,4 +32,5 @@ @Override protected void addUserInputPages() { } + } Modified: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.eclipse.jst.server.generic.openejb/maven-eclipse.xml URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.eclipse.jst.server.generic.openejb/maven-eclipse.xml?rev=605823&r1=605822&r2=605823&view=diff ============================================================================== --- openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.eclipse.jst.server.generic.openejb/maven-eclipse.xml (original) +++ openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.eclipse.jst.server.generic.openejb/maven-eclipse.xml Wed Dec 19 23:49:19 2007 @@ -1,14 +0,0 @@ -<project default="copy-resources"> - <target name="init"/> - <target name="copy-resources" depends="init"> - <copy todir="target/classes/META-INF" filtering="false"> - <fileset dir="META-INF" includes="MANIFEST.MF"/> - </copy> - <copy todir="target/classes/buildfiles" filtering="false"> - <fileset dir="buildfiles" includes="*"/> - </copy> - <copy todir="target/classes/servers" filtering="false"> - <fileset dir="servers" includes="*"/> - </copy> - </target> -</project> \ No newline at end of file Modified: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/pom.xml URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/pom.xml?rev=605823&r1=605822&r2=605823&view=diff ============================================================================== --- openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/pom.xml (original) +++ openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/pom.xml Wed Dec 19 23:49:19 2007 @@ -1,148 +1,150 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ 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. - --> -<!-- $Rev: 577554 $ $Date: 2007-09-20 06:35:12 +0100 (Thu, 20 Sep 2007) $ --> -<project> - <modelVersion>4.0.0</modelVersion> - <groupId>org.apache.openejb</groupId> - <artifactId>eclipse-plugins-parent</artifactId> - <packaging>pom</packaging> - <name>${artifactId}</name> - <parent> - <groupId>org.apache.openejb</groupId> - <artifactId>eclipse-plugins</artifactId> - <version>1.0.0</version> - <relativePath>../pom.xml</relativePath> - </parent> - <build> - <plugins> - <plugin> - <artifactId>maven-clean-plugin</artifactId> - <inherited>false</inherited> - <configuration> - <filesets> - <fileset> - <directory>.</directory> - <includes> - <include>.metadata</include> - </includes> - </fileset> - </filesets> - </configuration> - </plugin> - </plugins> - <pluginManagement> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-eclipse-plugin</artifactId> - <configuration> - <additionalProjectnatures> - <projectnature>org.eclipse.pde.PluginNature</projectnature> - </additionalProjectnatures> - <classpathContainers> - <classpathContainer>org.eclipse.pde.core.requiredPlugins</classpathContainer> - <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer> - </classpathContainers> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.geronimo.devtools</groupId> - <artifactId>maven-eclipsepde-plugin</artifactId> - <executions> - <execution> - <id>initialize</id> - <phase>validate</phase> - <goals> - <goal>manifestbundles</goal> - <goal>install</goal> - </goals> - </execution> - <execution> - <id>validate-bundle-classpath</id> - <phase>process-resources</phase> - <goals> - <goal>validatemanifest</goal> - </goals> - <configuration> - <classpathEntriesDir>lib</classpathEntriesDir> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <artifactId>maven-jar-plugin</artifactId> - <configuration> - <archive> - <manifestFile>${basedir}/META-INF/MANIFEST.MF</manifestFile> - </archive> - </configuration> - </plugin> - <plugin> - <artifactId>maven-antrun-plugin</artifactId> - <executions> - <!-- workaround for bugzilla 147936 --> - <execution> - <id>backup</id> - <phase>process-sources</phase> - <configuration> - <tasks> - <copy file="${basedir}/.classpath" todir="${project.build.directory}" overwrite="false" failonerror="false"/> - <copy file="${basedir}/.project" todir="${project.build.directory}" overwrite="false" failonerror="false"/> - </tasks> - </configuration> - <goals> - <goal>run</goal> - </goals> - </execution> - <execution> - <id>restore</id> - <phase>compile</phase> - <configuration> - <tasks> - <copy file="${project.build.directory}/.classpath" todir="${basedir}" overwrite="true" failonerror="false"/> - <copy file="${project.build.directory}/.project" todir="${basedir}" overwrite="true" failonerror="false"/> - </tasks> - </configuration> - <goals> - <goal>run</goal> - </goals> - </execution> - <!-- /workaround --> - </executions> - </plugin> - <plugin> - <artifactId>maven-clean-plugin</artifactId> - <configuration> - <filesets> - <fileset> - <directory>.</directory> - <includes> - <include>lib</include> - </includes> - </fileset> - </filesets> - </configuration> - </plugin> - </plugins> - </pluginManagement> - </build> - <modules> - <module>org.apache.openejb.helper.annotation</module> - <module>org.eclipse.jst.server.generic.openejb</module> - </modules> -</project> +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ 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. + --> +<!-- $Rev: 577554 $ $Date: 2007-09-20 06:35:12 +0100 (Thu, 20 Sep 2007) $ --> +<project> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.openejb</groupId> + <artifactId>eclipse-plugins-parent</artifactId> + <packaging>pom</packaging> + <name>${artifactId}</name> + <parent> + <groupId>org.apache.openejb</groupId> + <artifactId>eclipse-plugins</artifactId> + <version>1.0.0</version> + <relativePath>../pom.xml</relativePath> + </parent> + <build> + <plugins> + <plugin> + <artifactId>maven-clean-plugin</artifactId> + <inherited>false</inherited> + <configuration> + <filesets> + <fileset> + <directory>.</directory> + <includes> + <include>.metadata</include> + </includes> + </fileset> + </filesets> + </configuration> + </plugin> + </plugins> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-eclipse-plugin</artifactId> + <configuration> + <additionalProjectnatures> + <projectnature>org.eclipse.pde.PluginNature</projectnature> + </additionalProjectnatures> + <classpathContainers> + <classpathContainer>org.eclipse.pde.core.requiredPlugins</classpathContainer> + <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer> + </classpathContainers> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.geronimo.devtools</groupId> + <artifactId>maven-eclipsepde-plugin</artifactId> + <executions> + <execution> + <id>initialize</id> + <phase>validate</phase> + <goals> + <goal>manifestbundles</goal> + <goal>install</goal> + </goals> + </execution> + <execution> + <id>validate-bundle-classpath</id> + <phase>process-resources</phase> + <goals> + <goal>validatemanifest</goal> + </goals> + <configuration> + <classpathEntriesDir>lib</classpathEntriesDir> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-jar-plugin</artifactId> + <configuration> + <archive> + <manifestFile>${basedir}/META-INF/MANIFEST.MF</manifestFile> + </archive> + </configuration> + </plugin> + <plugin> + <artifactId>maven-antrun-plugin</artifactId> + <executions> + <!-- workaround for bugzilla 147936 --> + <execution> + <id>backup</id> + <phase>process-sources</phase> + <configuration> + <tasks> + <copy file="${basedir}/.classpath" todir="${project.build.directory}" overwrite="false" failonerror="false"/> + <copy file="${basedir}/.project" todir="${project.build.directory}" overwrite="false" failonerror="false"/> + </tasks> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + <execution> + <id>restore</id> + <phase>compile</phase> + <configuration> + <tasks> + <copy file="${project.build.directory}/.classpath" todir="${basedir}" overwrite="true" failonerror="false"/> + <copy file="${project.build.directory}/.project" todir="${basedir}" overwrite="true" failonerror="false"/> + </tasks> + </configuration> + <goals> + <goal>run</goal> + </goals> + + </execution> + <!-- /workaround --> + </executions> + </plugin> + <plugin> + <artifactId>maven-clean-plugin</artifactId> + <configuration> + <filesets> + <fileset> + <directory>.</directory> + <includes> + <include>lib</include> + </includes> + </fileset> + </filesets> + </configuration> + </plugin> + </plugins> + </pluginManagement> + </build> + <modules> + <module>org.apache.openejb.helper.annotation</module> + <module>org.apache.openejb.helper.annotation.test</module> + <module>org.eclipse.jst.server.generic.openejb</module> + </modules> +</project>
