Skip to content

Commit

Permalink
FORGE-1824 - All external leaks should be resolved and functional (ex…
Browse files Browse the repository at this point in the history
…cept javaee/tests still uses javaee-impl)
  • Loading branch information
lincolnthree committed May 15, 2014
1 parent 8407cc4 commit 13a315f
Show file tree
Hide file tree
Showing 7 changed files with 251 additions and 89 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* Copyright 2013 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.jboss.forge.addon.javaee.faces;

import java.io.FileNotFoundException;

import javax.faces.validator.Validator;

import org.jboss.forge.addon.parser.java.resources.JavaResource;
import org.jboss.forge.addon.projects.Project;
import org.jboss.forge.addon.resource.DirectoryResource;
import org.jboss.forge.roaster.model.source.JavaClassSource;
import org.jboss.forge.roaster.model.source.MethodSource;

/**
* This class contains Faces specific operations
*
* @author <a href="mailto:ggastald@redhat.com">George Gastaldi</a>
*
*/
public interface FacesOperations
{
/**
* Creates a new {@link JavaResource} in the specified project. If no project is available, use
* {@link FacesOperations#newBackingBean(DirectoryResource, String, String)}
*
* @param project the current project to create the backing bean. Must not be null
* @param backingBeanName the name of the backing bean
* @param backingBeanPackage the package of the backing bean to be created
* @return the created {@link JavaResource}
*/
public JavaResource newBackingBean(Project project, String backingBeanName, String backingBeanPackage)
throws FileNotFoundException;

/**
* Creates a new {@link JavaResource} in the specified target. If a project is available, use
* {@link FacesOperations#newBackingBean(Project, String, String)}
*
* @param target the target directory resource to create the backing bean
* @param backingBeanName the name of the backing bean
* @param backingBeanPackage the package of the backing bean to be created
* @return the created {@link JavaResource}
*/
public JavaResource newBackingBean(DirectoryResource target, String backingBeanName, String backingBeanPackage);

/**
* Creates a new {@link JavaResource} in the specified project. If no project is available, use
* {@link FacesOperations#newConverter(DirectoryResource, String, String)}
*
* @param project the current project to create the converter. Must not be null
* @param converterName the name of the converter
* @param converterPackage the package of the converter to be created
* @return the created {@link JavaResource}
*/
public JavaResource newConverter(Project project, String converterName, String converterPackage)
throws FileNotFoundException;

/**
* Creates a new {@link JavaResource} in the specified target. If a project is available, use
* {@link FacesOperations#newConverter(Project, String, String)}
*
* @param target the target directory resource to create this class
* @param converterName the name of the converter
* @param converterPackage the package of the converter to be created
* @return the created {@link JavaResource}
*/
public JavaResource newConverter(DirectoryResource target, String converterName, String converterPackage);

/**
* Creates a new {@link JavaResource} in the specified project. If no project is available, use
* {@link FacesOperations#newValidator(DirectoryResource, String, String)}
*
* @param project the current project to create the validator. Must not be null
* @param validatorName the name of the validator
* @param validatorPackage the package of the validator to be created
* @return the created {@link JavaResource}
*/
public JavaResource newValidator(Project project, String validatorName, String validatorPackage)
throws FileNotFoundException;

/**
* Creates a new {@link JavaResource} in the specified target. If a project is available, use
* {@link FacesOperations#newConverter(Project, String, String)}
*
* @param target the target directory resource to create the validator. Must not be null
* @param validatorName the name of the validator
* @param validatorPackage the package of the validator to be created
* @return the created {@link JavaResource}
*/
public JavaResource newValidator(DirectoryResource target, String validatorName, String validatorPackage);

/**
* Adds a {@link Validator} method to the given {@link JavaResource}.
*/
public MethodSource<JavaClassSource> addValidatorMethod(JavaResource target, String name)
throws FileNotFoundException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* Copyright 2013 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.jboss.forge.addon.javaee.jpa;

import java.io.FileNotFoundException;

import javax.persistence.GenerationType;

import org.jboss.forge.addon.parser.java.resources.JavaResource;
import org.jboss.forge.addon.projects.Project;
import org.jboss.forge.addon.resource.DirectoryResource;
import org.jboss.forge.addon.resource.FileResource;
import org.jboss.forge.roaster.model.JavaClass;

/**
* Defines JPA specific operations
*
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
*/
public interface PersistenceOperations
{
public static final String DEFAULT_UNIT_SUFFIX = "-persistence-unit";
public static final String DEFAULT_UNIT_DESC = "Forge Persistence Unit";

/**
* Setups JPA in the project
*/
public FileResource<?> setup(String unitName, Project project, JPADataSource dataSource, boolean configureMetadata);

/**
* Creates a new {@link JavaResource} in the specified project. If no project is available, use
* {@link PersistenceOperations#newEntity(DirectoryResource, String, String, GenerationType)}
*
* @param project the current project to create the entity. Must not be null
* @param entityName the name of the entity
* @param entityPackage the package of the entity to be created
* @param idStrategy the ID strategy chosen for this entity
* @return the created java resource
* @throws FileNotFoundException if something wrong happens while saving the {@link JavaClass}
*/
public JavaResource newEntity(Project project, String entityName, String entityPackage, GenerationType idStrategy,
String tableName) throws FileNotFoundException;

/**
* Creates a new {@link JavaResource} in the specified target. If a project is available, use
* {@link PersistenceOperations#newEntity(Project, String, String, GenerationType)}
*
* @param target the target directory resource to create this class
* @param entityName the name of the entity
* @param entityPackage the package of the entity to be created
* @param idStrategy the ID strategy chosen for this entity
* @param tableName the table name (optional)
* @return the created java resource
* @throws FileNotFoundException if something wrong happens while saving the {@link JavaClass}
*/
public JavaResource newEntity(DirectoryResource target, String entityName, String entityPackage,
GenerationType idStrategy, String tableName);

/**
* Creates a new {@link JavaResource} in the specified project. If no project is available, use
* {@link PersistenceOperations#newEntity(DirectoryResource, String, String, GenerationType)}
*
* @param project the current project to create the entity. Must not be null
* @param entityName the name of the entity
* @param entityPackage the package of the entity to be created
* @param idStrategy the ID strategy chosen for this entity
* @return the created java resource
* @throws FileNotFoundException if something wrong happens while saving the {@link JavaClass}
*/
public JavaResource newEntity(Project project, String entityName, String entityPackage, GenerationType idStrategy)
throws FileNotFoundException;

/**
* Creates a new {@link JavaResource} in the specified target. If a project is available, use
* {@link PersistenceOperations#newEntity(Project, String, String, GenerationType)}
*
* @param target the target directory resource to create this class
* @param entityName the name of the entity
* @param entityPackage the package of the entity to be created
* @param idStrategy the ID strategy chosen for this entity
* @return the created java resource
* @throws FileNotFoundException if something wrong happens while saving the {@link JavaClass}
*/
public JavaResource newEntity(DirectoryResource target, String entityName, String entityPackage,
GenerationType idStrategy);

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,22 @@

/**
* This class contains Faces specific operations
*
*
* @author <a href="mailto:ggastald@redhat.com">George Gastaldi</a>
*
*
*/
public class FacesOperations
public class FacesOperationsImpl implements FacesOperations
{
/**
* Creates a new {@link JavaResource} in the specified project. If no project is available, use
* {@link FacesOperations#newBackingBean(DirectoryResource, String, String)}
*
*
* @param project the current project to create the backing bean. Must not be null
* @param backingBeanName the name of the backing bean
* @param backingBeanPackage the package of the backing bean to be created
* @return the created {@link JavaResource}
*/
@Override
public JavaResource newBackingBean(Project project, String backingBeanName, String backingBeanPackage)
throws FileNotFoundException
{
Expand All @@ -47,32 +48,34 @@ public JavaResource newBackingBean(Project project, String backingBeanName, Stri
return java.saveJavaSource(javaClass);
}

/**
* Creates a new {@link JavaResource} in the specified target. If a project is available, use
* {@link FacesOperations#newBackingBean(Project, String, String)}
*
* @param target the target directory resource to create the backing bean
* @param backingBeanName the name of the backing bean
* @param backingBeanPackage the package of the backing bean to be created
* @return the created {@link JavaResource}
*/
public JavaResource newBackingBean(DirectoryResource target, String backingBeanName, String backingBeanPackage)
{
JavaClassSource javaClass = createBackingBean(backingBeanName, backingBeanPackage);
JavaResource javaResource = getJavaResource(target, javaClass.getName());
javaResource.setContents(javaClass);
return javaResource;
}
/**
* Creates a new {@link JavaResource} in the specified target. If a project is available, use
* {@link FacesOperations#newBackingBean(Project, String, String)}
*
* @param target the target directory resource to create the backing bean
* @param backingBeanName the name of the backing bean
* @param backingBeanPackage the package of the backing bean to be created
* @return the created {@link JavaResource}
*/
@Override
public JavaResource newBackingBean(DirectoryResource target, String backingBeanName, String backingBeanPackage)
{
JavaClassSource javaClass = createBackingBean(backingBeanName, backingBeanPackage);
JavaResource javaResource = getJavaResource(target, javaClass.getName());
javaResource.setContents(javaClass);
return javaResource;
}

/**
* Creates a new {@link JavaResource} in the specified project. If no project is available, use
* {@link FacesOperations#newConverter(DirectoryResource, String, String)}
*
*
* @param project the current project to create the converter. Must not be null
* @param converterName the name of the converter
* @param converterPackage the package of the converter to be created
* @return the created {@link JavaResource}
*/
@Override
public JavaResource newConverter(Project project, String converterName, String converterPackage)
throws FileNotFoundException
{
Expand All @@ -84,12 +87,13 @@ public JavaResource newConverter(Project project, String converterName, String c
/**
* Creates a new {@link JavaResource} in the specified target. If a project is available, use
* {@link FacesOperations#newConverter(Project, String, String)}
*
*
* @param target the target directory resource to create this class
* @param converterName the name of the converter
* @param converterPackage the package of the converter to be created
* @return the created {@link JavaResource}
*/
@Override
public JavaResource newConverter(DirectoryResource target, String converterName, String converterPackage)
{
JavaClassSource javaClass = createConverter(converterName, converterPackage);
Expand Down Expand Up @@ -117,12 +121,13 @@ private JavaClassSource createBackingBean(String beanName, String beanPackage)
/**
* Creates a new {@link JavaResource} in the specified project. If no project is available, use
* {@link FacesOperations#newValidator(DirectoryResource, String, String)}
*
*
* @param project the current project to create the validator. Must not be null
* @param validatorName the name of the validator
* @param validatorPackage the package of the validator to be created
* @return the created {@link JavaResource}
*/
@Override
public JavaResource newValidator(Project project, String validatorName, String validatorPackage)
throws FileNotFoundException
{
Expand All @@ -134,12 +139,13 @@ public JavaResource newValidator(Project project, String validatorName, String v
/**
* Creates a new {@link JavaResource} in the specified target. If a project is available, use
* {@link FacesOperations#newConverter(Project, String, String)}
*
*
* @param target the target directory resource to create the validator. Must not be null
* @param validatorName the name of the validator
* @param validatorPackage the package of the validator to be created
* @return the created {@link JavaResource}
*/
@Override
public JavaResource newValidator(DirectoryResource target, String validatorName, String validatorPackage)
{
JavaClassSource javaClass = createValidator(validatorName, validatorPackage);
Expand All @@ -165,6 +171,7 @@ private JavaResource getJavaResource(final DirectoryResource sourceDir, final St
return target;
}

@Override
public MethodSource<JavaClassSource> addValidatorMethod(JavaResource target, String name)
throws FileNotFoundException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/
@SuppressWarnings("rawtypes")
@FacetConstraint(DependencyFacet.class)
public class FacesSetupWizardImpl extends AbstractJavaEECommand
public class FacesSetupWizardImpl extends AbstractJavaEECommand implements FacesSetupWizard
{

@Override
Expand Down
Loading

0 comments on commit 13a315f

Please sign in to comment.