Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 299086
Collapse All | Expand All

(-)META-INF/MANIFEST.MF (+1 lines)
Lines 47-50 Link Here
47
 org.eclipse.jst.jee.ui;bundle-version="[1.0.100,2.0.0)"
47
 org.eclipse.jst.jee.ui;bundle-version="[1.0.100,2.0.0)"
48
Eclipse-LazyStart: true
48
Eclipse-LazyStart: true
49
Bundle-RequiredExecutionEnvironment: J2SE-1.5
49
Bundle-RequiredExecutionEnvironment: J2SE-1.5
50
Import-Package: org.eclipse.emf.codegen.jet
50
Bundle-ActivationPolicy: lazy
51
Bundle-ActivationPolicy: lazy
(-)ejb_ui/org/eclipse/jst/ejb/ui/internal/util/EJBUIMessages.java (-1 / +6 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Oracle - EJB Timer
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jst.ejb.ui.internal.util;
12
package org.eclipse.jst.ejb.ui.internal.util;
12
13
Lines 107-113 Link Here
107
	public static String REMOTE_COMPONENT_INTERFACE_TOOLTIP;
108
	public static String REMOTE_COMPONENT_INTERFACE_TOOLTIP;
108
	public static String REMOTE_HOME_INTERFACE_TOOLTIP;
109
	public static String REMOTE_HOME_INTERFACE_TOOLTIP;
109
	public static String EJB_CLIENT_JAR_GROUP;
110
	public static String EJB_CLIENT_JAR_GROUP;
110
	
111
112
	//EJB Timer
113
    public static String timerWizardTitle;
114
    public static String timerWizardDescription;
115
    public static String timerScheduleLabel;
111
116
112
	static {
117
	static {
113
		NLS.initializeMessages(BUNDLE_NAME, EJBUIMessages.class);
118
		NLS.initializeMessages(BUNDLE_NAME, EJBUIMessages.class);
(-)ejb_ui/org/eclipse/jst/ejb/ui/internal/wizard/AddEjbTimerWizard.java (+47 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Oracle and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * Ludovic Champenois ludo@java.net
10
 *******************************************************************************/
11
12
package org.eclipse.jst.ejb.ui.internal.wizard;
13
14
import org.eclipse.jst.ejb.ui.internal.util.EJBUIMessages;
15
import org.eclipse.jst.j2ee.ejb.internal.operations.AddEjbTimerDataModelProvider;
16
import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
17
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
18
import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider;
19
20
@SuppressWarnings("restriction")
21
/* 
22
 * Java EE 6 EJB Timer wizard
23
 */
24
public class AddEjbTimerWizard extends NewEnterpriseBeanWizard {
25
26
	public AddEjbTimerWizard() {
27
		this(null);
28
	}
29
30
	public AddEjbTimerWizard(IDataModel model) {
31
		super(model);
32
		setWindowTitle(EJBUIMessages.timerWizardTitle);
33
	}
34
35
	@Override
36
	protected void doAddPages() {
37
		AddEjbTimerWizardPage page1 = new AddEjbTimerWizardPage(getDataModel(),
38
				"page1", EJBUIMessages.timerWizardDescription, //$NON-NLS-1$
39
				EJBUIMessages.timerWizardTitle, J2EEProjectUtilities.EJB);
40
		addPage(page1);
41
	}
42
43
	@Override
44
	protected IDataModelProvider getDefaultProvider() {
45
		return new AddEjbTimerDataModelProvider();
46
	}
47
}
(-)ejb_ui/org/eclipse/jst/ejb/ui/internal/wizard/AddEjbTimerWizardPage.java (+66 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Oracle and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * Ludovic Champenois ludo@java.net
10
 *******************************************************************************/
11
12
13
package org.eclipse.jst.ejb.ui.internal.wizard;
14
15
import org.eclipse.jst.ejb.ui.internal.util.EJBUIMessages;
16
import org.eclipse.jst.j2ee.ejb.internal.operations.AddEjbTimerDataModelProvider;
17
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.layout.GridData;
19
import org.eclipse.swt.widgets.Composite;
20
import org.eclipse.swt.widgets.Label;
21
import org.eclipse.swt.widgets.Text;
22
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
23
24
@SuppressWarnings("restriction")
25
/* 
26
 * Java EE 6 EJB Timer wizard page
27
 */
28
public class AddEjbTimerWizardPage extends NewEnterpriseBeanClassWizardPage {
29
30
	private Text scheduleText;
31
32
	public AddEjbTimerWizardPage(IDataModel mode, String pageName,
33
			String pageDesc, String pageTitle, String moduleType) {
34
		super(mode, pageName, pageDesc, pageTitle, moduleType);
35
	}
36
37
	@Override
38
	protected Composite createTopLevelComposite(Composite parent) {
39
		Composite composite = super.createTopLevelComposite(parent);
40
41
		addSeperator(composite, 3);
42
		
43
		new Label(composite, SWT.LEFT).setText(EJBUIMessages.timerScheduleLabel);
44
		scheduleText = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.WRAP /*| SWT.V_SCROLL*/);
45
		GridData layoutData = new GridData(GridData.FILL_BOTH);
46
		layoutData.verticalSpan = 2;
47
		initializeDialogUnits(scheduleText);
48
		layoutData.heightHint = convertHeightInCharsToPixels(2);
49
		scheduleText.setLayoutData(layoutData);
50
		synchHelper.synchText(scheduleText,
51
				AddEjbTimerDataModelProvider.SCHEDULE, null);
52
53
		return composite;
54
	}
55
	
56
	@Override
57
	protected String[] getValidationPropertyNames() {
58
		String[] base = super.getValidationPropertyNames();
59
		String[] result = new String[base.length + 1];
60
		System.arraycopy(base, 0, result, 0, base.length);
61
		result[base.length] = AddEjbTimerDataModelProvider.SCHEDULE;
62
		return result;
63
	}
64
65
66
}
(-)ejb_ui/org/eclipse/jst/ejb/ui/internal/wizard/IEjbWizardConstants.java (+5 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 * Kaloyan Raev, kaloyan.raev@sap.com - initial API and implementation
9
 * Kaloyan Raev, kaloyan.raev@sap.com - initial API and implementation
10
 * Ludovic Champenois ludo@java.net
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jst.ejb.ui.internal.wizard;
12
package org.eclipse.jst.ejb.ui.internal.wizard;
12
13
Lines 48-51 Link Here
48
	public static final String MESSAGE_LISTENER_INTERFACE_HYPERLINK_TOOLTIP = EJBUIMessages.MESSAGE_LISTENER_INTERFACE_HYPERLINK_TOOLTIP;
49
	public static final String MESSAGE_LISTENER_INTERFACE_HYPERLINK_TOOLTIP = EJBUIMessages.MESSAGE_LISTENER_INTERFACE_HYPERLINK_TOOLTIP;
49
	public static final String CLICK_TO_SELECT = EJBUIMessages.CLICK_TO_SELECT;
50
	public static final String CLICK_TO_SELECT = EJBUIMessages.CLICK_TO_SELECT;
50
	
51
	
52
    public static final  String timerWizardTitle = EJBUIMessages.timerWizardTitle;
53
    public static final  String timerWizardDescription = EJBUIMessages.timerWizardDescription;
54
    public static final  String timerScheduleLabel = EJBUIMessages.timerScheduleLabel;
55
	
51
}
56
}
(-)plugin.properties (+5 lines)
Lines 7-12 Link Here
7
#
7
#
8
# Contributors:
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
9
#     IBM Corporation - initial API and implementation
10
#     Oracle - EJB Timer
10
###############################################################################
11
###############################################################################
11
providerName=Eclipse.org
12
providerName=Eclipse.org
12
pluginName=WTP EJB UI Plug-in
13
pluginName=WTP EJB UI Plug-in
Lines 103-105 Link Here
103
BeanWebRegionWizard.description=Create a new EJB 3.x Session Bean
104
BeanWebRegionWizard.description=Create a new EJB 3.x Session Bean
104
MDBEjbRegionWizard.name=Message-Driven Bean (EJB 3.x)
105
MDBEjbRegionWizard.name=Message-Driven Bean (EJB 3.x)
105
MDBEjbRegionWizard.description=Create a new EJB 3.x Message-Driven Bean
106
MDBEjbRegionWizard.description=Create a new EJB 3.x Message-Driven Bean
107
108
109
EJBTIMER.ejbtimerlabel=EJB Timer (Java EE 6)
110
EJBTIMER.ejbtimer.BeanWebRegionWizard.description=Create a new Java EE 6 EJB Timer
(-)plugin.xml (+24 lines)
Lines 82-87 Link Here
82
            %MDBEjbRegionWizard.description
82
            %MDBEjbRegionWizard.description
83
         </description>
83
         </description>
84
      </wizard>
84
      </wizard>
85
      
86
       <wizard
87
             category="org.eclipse.jst.ejb.ui"
88
             class="org.eclipse.jst.ejb.ui.internal.wizard.AddEjbTimerWizard"
89
             icon="icons/full/ctool16/sessionbean_wiz.gif"
90
             id="org.eclipse.jst.ejb.ui.internal.wizard.AddEjbTimerWizard"
91
             name="%EJBTIMER.ejbtimerlabel">
92
		 <class
93
               class="org.eclipse.jst.ejb.ui.internal.wizard.AddEjbTimerWizard">
94
            <parameter
95
                  name="javaeeartifact"
96
                  value="true">
97
            </parameter>
98
            <parameter
99
                  name="menuIndex"
100
                  value="37">
101
            </parameter>
102
         </class>
103
         <description>
104
            %EJBTIMER.ejbtimer.BeanWebRegionWizard.description
105
         </description>
106
       </wizard>      
107
      
108
      
85
   </extension>
109
   </extension>
86
<!-- Navigator Object Contributions -->
110
<!-- Navigator Object Contributions -->
87
<!-- EJB Group Contributions 
111
<!-- EJB Group Contributions 
(-)property_files/ejb_ui.properties (-1 / +6 lines)
Lines 7-12 Link Here
7
#
7
#
8
# Contributors:
8
# Contributors:
9
# IBM Corporation - initial API and implementation
9
# IBM Corporation - initial API and implementation
10
# Oracle - EJB Timer
10
###############################################################################
11
###############################################################################
11
KEY_0=Failed to find the image "{0}".
12
KEY_0=Failed to find the image "{0}".
12
KEY_1=New EJB Project
13
KEY_1=New EJB Project
Lines 91-94 Link Here
91
MESSAGE_LISTENER_INTERFACE_HYPERLINK=Message &listener: 
92
MESSAGE_LISTENER_INTERFACE_HYPERLINK=Message &listener: 
92
MESSAGE_LISTENER_INTERFACE_HYPERLINK_TOOLTIP=Set message listener interface
93
MESSAGE_LISTENER_INTERFACE_HYPERLINK_TOOLTIP=Set message listener interface
93
CLICK_TO_SELECT=<click to select>
94
CLICK_TO_SELECT=<click to select>
94
EJB_CLIENT_JAR_GROUP=EJB Client JAR
95
EJB_CLIENT_JAR_GROUP=EJB Client JAR
96
97
timerWizardTitle=Create EJB Timer Callback
98
timerWizardDescription=Create Java class with an added EJB Timer Callback method.
99
timerScheduleLabel=Schedule: 
(-)ejb/org/eclipse/jst/j2ee/ejb/internal/operations/AddEjbTimerClassOperation.java (+71 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Oracle and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * Ludovic Champenois ludo@java.net
10
 *******************************************************************************/
11
12
package org.eclipse.jst.j2ee.ejb.internal.operations;
13
14
import java.lang.reflect.InvocationTargetException;
15
import java.lang.reflect.Method;
16
17
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.IProgressMonitor;
19
import org.eclipse.emf.codegen.jet.JETException;
20
import org.eclipse.jdt.core.IPackageFragment;
21
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
22
import org.eclipse.wst.common.frameworks.internal.enablement.nonui.WFTWrappedException;
23
24
@SuppressWarnings("restriction")
25
public class AddEjbTimerClassOperation extends NewEnterpriseBeanClassOperation {
26
27
	/**
28
	 * folder location of the EJB Timer creation templates directory
29
	 */
30
	protected static final String TEMPLATE_FILE = "/templates/ejbtimer.javajet"; //$NON-NLS-1$
31
32
	public AddEjbTimerClassOperation(IDataModel dataModel) {
33
		super(dataModel);
34
	}
35
36
	@Override
37
	protected void generateUsingTemplates(IProgressMonitor monitor,
38
			IPackageFragment fragment) throws WFTWrappedException,
39
			CoreException {
40
		// Create the enterprise bean template model
41
		AddEjbTimerTemplateModel tempModel = new AddEjbTimerTemplateModel(model);
42
		// Using the WTPJetEmitter, generate the java source based on the bean
43
		// template model
44
		try {
45
			if (fragment != null) {
46
				// Create the EJB Timer java file
47
				EjbTimerTemplate tempImpl = EjbTimerTemplate.create(null);
48
49
				try {
50
					Method method = tempImpl.getClass().getMethod("generate", //$NON-NLS-1$
51
							new Class[] { Object.class });
52
					String source = (String) method.invoke(tempImpl, tempModel);
53
					String javaFileName = tempModel.getClassName() + ".java"; //$NON-NLS-1$
54
					createJavaFile(monitor, fragment, source, javaFileName);
55
				} catch (SecurityException e) {
56
					throw new JETException(e);
57
				} catch (NoSuchMethodException e) {
58
					throw new JETException(e);
59
				} catch (IllegalArgumentException e) {
60
					throw new JETException(e);
61
				} catch (IllegalAccessException e) {
62
					throw new JETException(e);
63
				} catch (InvocationTargetException e) {
64
					throw new JETException(e);
65
				}
66
			}
67
		} catch (Exception e) {
68
			throw new WFTWrappedException(e);
69
		}
70
	}
71
}
(-)ejb/org/eclipse/jst/j2ee/ejb/internal/operations/AddEjbTimerDataModelProvider.java (+98 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Oracle and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * Ludovic Champenois ludo@java.net
10
 *******************************************************************************/
11
12
13
package org.eclipse.jst.j2ee.ejb.internal.operations;
14
15
import static org.eclipse.jst.j2ee.ejb.internal.operations.INewEnterpriseBeanClassDataModelProperties.EJB_NAME;
16
17
import java.util.Set;
18
19
import org.eclipse.core.runtime.IStatus;
20
import org.eclipse.jst.j2ee.internal.common.operations.NewJavaClassDataModelProvider;
21
import org.eclipse.jst.j2ee.internal.common.operations.NewJavaEEArtifactClassOperation;
22
import org.eclipse.jst.j2ee.internal.ejb.project.operations.EJBCreationResourceHandler;
23
import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
24
import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider;
25
import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin;
26
27
28
@SuppressWarnings("restriction")
29
public class AddEjbTimerDataModelProvider extends
30
		NewEnterpriseBeanClassDataModelProvider {
31
32
	public static final String SCHEDULE = "AddEjbTimer.SCHEDULE"; //$NON-NLS-1$
33
34
	@Override
35
	public IDataModelOperation getDefaultOperation() {
36
		return new AddEnterpriseBeanOperation(getDataModel()) {
37
38
			@Override
39
			protected NewJavaEEArtifactClassOperation getNewClassOperation() {
40
				return new AddEjbTimerClassOperation(getDataModel());
41
			}
42
		};
43
	}
44
45
	/**
46
	 * Subclasses may extend this method to add their own data model's
47
	 * properties as valid base properties.
48
	 * 
49
	 * @see org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider#getPropertyNames()
50
	 */
51
	@Override
52
	public Set<String> getPropertyNames() {
53
		// Add Bean specific properties defined in this data model
54
		Set<String> propertyNames = super.getPropertyNames();
55
56
		propertyNames.add(SCHEDULE);
57
58
		return propertyNames;
59
	}
60
61
	/**
62
	 * Subclasses may extend this method to provide their own default values for
63
	 * any of the properties in the data model hierarchy. This method does not
64
	 * accept a null parameter. It may return null.
65
	 * 
66
	 * @see NewJavaClassDataModelProvider#getDefaultProperty(String)
67
	 * @see IDataModelProvider#getDefaultProperty(String)
68
	 * 
69
	 * @param propertyName
70
	 * @return Object default value of property
71
	 */
72
	@Override
73
	public Object getDefaultProperty(String propertyName) {
74
		if (propertyName.equals(SCHEDULE)) {
75
			return EJBCreationResourceHandler.timerScheduleDefault;
76
		}
77
		
78
		// Otherwise check super for default value for property
79
		return super.getDefaultProperty(propertyName);
80
	}
81
82
	@Override
83
	public IStatus validate(String propertyName) {
84
		// we need to override to remove the error condition for EJB_NAME
85
		if (EJB_NAME.equals(propertyName)){
86
			return null;
87
		}
88
89
		if (SCHEDULE.equals(propertyName)) {
90
			String value = (String) getProperty(SCHEDULE);
91
			if (value == null || value.trim().length() == 0) {
92
				return WTPCommonPlugin.createErrorStatus(EJBCreationResourceHandler.errorTimerScheduleMissing);
93
			}
94
		}
95
		IStatus status = super.validate(propertyName);
96
		return status;
97
	}
98
}
(-)ejb/org/eclipse/jst/j2ee/ejb/internal/operations/AddEjbTimerTemplateModel.java (+85 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Oracle and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * Ludovic Champenois ludo@java.net
10
 *******************************************************************************/
11
12
package org.eclipse.jst.j2ee.ejb.internal.operations;
13
14
import static org.eclipse.jst.j2ee.ejb.internal.operations.INewEnterpriseBeanClassDataModelProperties.EJB_NAME;
15
import static org.eclipse.jst.j2ee.ejb.internal.operations.INewEnterpriseBeanClassDataModelProperties.MAPPED_NAME;
16
17
import java.util.Collection;
18
import java.util.Hashtable;
19
import java.util.Iterator;
20
import java.util.Map;
21
22
import org.eclipse.jst.j2ee.internal.common.operations.Method;
23
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
24
25
@SuppressWarnings("restriction")
26
public class AddEjbTimerTemplateModel extends CreateEnterpriseBeanTemplateModel {
27
28
	public static final String QUALIFIED_SCHEDULE = "javax.ejb.Schedule"; //$NON-NLS-1$
29
	public static final String QUALIFIED_TIMER = "javax.ejb.Timer"; //$NON-NLS-1$
30
	public static final String QUALIFIED_STATELESS = "javax.ejb.Stateless"; //$NON-NLS-1$
31
32
	public static final String SCHEDULED_TIMEOUT = "scheduledTimeout"; //$NON-NLS-1$
33
34
	public AddEjbTimerTemplateModel(IDataModel adataModel) {
35
		super(adataModel);
36
	}
37
38
	@Override
39
	public Collection<String> getImports() {
40
		Collection<String> collection = super.getImports();
41
42
		collection.add(QUALIFIED_SCHEDULE);
43
		collection.add(QUALIFIED_STATELESS);
44
		collection.add(QUALIFIED_TIMER);
45
46
		return collection;
47
	}
48
49
	public Map<String, String> getClassAnnotationParams() {
50
		Map<String, String> result = new Hashtable<String, String>();
51
52
		String dispName = getProperty(EJB_NAME).trim();
53
		if (!dispName.equals(getClassName()) && (dispName.length() > 0)) {
54
			result.put(ATT_NAME, QUOTATION_STRING + dispName + QUOTATION_STRING);
55
		}
56
		String mappedName = getProperty(MAPPED_NAME).trim();
57
		if (mappedName != null && mappedName.length() > 0) {
58
			result.put(ATT_MAPPED_NAME, QUOTATION_STRING + mappedName + QUOTATION_STRING);
59
		}
60
61
		return result;
62
	}
63
64
	@Override
65
	public String getProperty(String propertyName) {
66
		return dataModel.getStringProperty(propertyName);
67
	}
68
69
	@Override
70
	public Collection<Method> getUnimplementedMethods() {
71
		Collection<Method> unimplementedMethods = super
72
				.getUnimplementedMethods();
73
		Iterator<Method> iterator = unimplementedMethods.iterator();
74
75
		while (iterator.hasNext()) {
76
			Method method = iterator.next();
77
			if (SCHEDULED_TIMEOUT.equals(method.getName())) {
78
				iterator.remove();
79
			}
80
		}
81
82
		return unimplementedMethods;
83
	}
84
85
}
(-)ejb/org/eclipse/jst/j2ee/ejb/internal/operations/EjbTimerTemplate.java (+239 lines)
Added Link Here
1
package org.eclipse.jst.j2ee.ejb.internal.operations;
2
3
import java.util.*;
4
5
import org.eclipse.jst.j2ee.internal.common.operations.*;
6
7
8
9
@SuppressWarnings("restriction")
10
public class EjbTimerTemplate {
11
  protected static String nl;
12
  public static synchronized EjbTimerTemplate create(String lineSeparator)
13
  {
14
    nl = lineSeparator;
15
    EjbTimerTemplate result = new EjbTimerTemplate();
16
    nl = null;
17
    return result;
18
  }
19
20
  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; //$NON-NLS-1$
21
  protected final String TEXT_1 = "package "; //$NON-NLS-1$
22
  protected final String TEXT_2 = ";"; //$NON-NLS-1$
23
  protected final String TEXT_3 = NL;
24
  protected final String TEXT_4 = NL + "import "; //$NON-NLS-1$
25
  protected final String TEXT_5 = ";"; //$NON-NLS-1$
26
  protected final String TEXT_6 = NL + NL + "@Stateless"; //$NON-NLS-1$
27
  protected final String TEXT_7 = NL + "public "; //$NON-NLS-1$
28
  protected final String TEXT_8 = "abstract "; //$NON-NLS-1$
29
  protected final String TEXT_9 = "final "; //$NON-NLS-1$
30
  protected final String TEXT_10 = "class "; //$NON-NLS-1$
31
  protected final String TEXT_11 = " extends "; //$NON-NLS-1$
32
  protected final String TEXT_12 = " implements "; //$NON-NLS-1$
33
  protected final String TEXT_13 = ", "; //$NON-NLS-1$
34
  protected final String TEXT_14 = " {"; //$NON-NLS-1$
35
  protected final String TEXT_15 = NL + NL + "    /**" + NL + "     * Default constructor. " + NL + "     */" + NL + "    public "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
36
  protected final String TEXT_16 = "() {" + NL + "        // TODO Auto-generated constructor stub" + NL + "    }"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
37
  protected final String TEXT_17 = NL + "       " + NL + "    /**" + NL + "     * @see "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
38
  protected final String TEXT_18 = "#"; //$NON-NLS-1$
39
  protected final String TEXT_19 = "("; //$NON-NLS-1$
40
  protected final String TEXT_20 = ")" + NL + "     */" + NL + "    public "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
41
  protected final String TEXT_21 = "("; //$NON-NLS-1$
42
  protected final String TEXT_22 = ") {" + NL + "        super("; //$NON-NLS-1$ //$NON-NLS-2$
43
  protected final String TEXT_23 = ");" + NL + "        // TODO Auto-generated constructor stub" + NL + "    }"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
44
  protected final String TEXT_24 = NL + NL + "\t/**" + NL + "     * @see "; //$NON-NLS-1$ //$NON-NLS-2$
45
  protected final String TEXT_25 = "#"; //$NON-NLS-1$
46
  protected final String TEXT_26 = "("; //$NON-NLS-1$
47
  protected final String TEXT_27 = ")" + NL + "     */" + NL + "    public "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
48
  protected final String TEXT_28 = " "; //$NON-NLS-1$
49
  protected final String TEXT_29 = "("; //$NON-NLS-1$
50
  protected final String TEXT_30 = ") {" + NL + "        // TODO Auto-generated method stub"; //$NON-NLS-1$ //$NON-NLS-2$
51
  protected final String TEXT_31 = NL + "\t\t\treturn "; //$NON-NLS-1$
52
  protected final String TEXT_32 = ";"; //$NON-NLS-1$
53
  protected final String TEXT_33 = NL + "    }"; //$NON-NLS-1$
54
  protected final String TEXT_34 = NL + "\t"; //$NON-NLS-1$
55
  protected final String TEXT_35 = NL + "\t@SuppressWarnings(\"unused\")" + NL + "\t@Schedule("; //$NON-NLS-1$ //$NON-NLS-2$
56
  protected final String TEXT_36 = ")" + NL + "    private void scheduledTimeout(final Timer t) {" + NL + "        System.out.println(\"@Schedule called at: \" + new java.util.Date());" + NL + "    }" + NL + "}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
57
58
	public String generate(Object argument)
59
  {
60
    final StringBuffer stringBuffer = new StringBuffer();
61
     AddEjbTimerTemplateModel model = (AddEjbTimerTemplateModel) argument; 
62
     /* This Content is provided under the terms and conditions of the Eclipse Public License Version 1.0 
63
("EPL"). A copy of the EPL is available at http://www.eclipse.org/org/documents/epl-v10.php 
64
For purposes of the EPL, "Program" will mean the Content. 
65
66
Copied from org.eclipse.jst.j2ee.ejb plugin. */ 
67
    
68
	model.removeFlags(CreateJavaEEArtifactTemplateModel.FLAG_QUALIFIED_SUPERCLASS_NAME); 
69
70
     /* This Content is provided under the terms and conditions of the Eclipse Public License Version 1.0 
71
("EPL"). A copy of the EPL is available at http://www.eclipse.org/org/documents/epl-v10.php 
72
For purposes of the EPL, "Program" will mean the Content. 
73
74
Copied from org.eclipse.jst.j2ee.ejb plugin. */ 
75
    
76
	if (model.getJavaPackageName() != null && model.getJavaPackageName().length() > 0) {
77
78
    stringBuffer.append(TEXT_1);
79
    stringBuffer.append( model.getJavaPackageName() );
80
    stringBuffer.append(TEXT_2);
81
    
82
	}
83
84
    stringBuffer.append(TEXT_3);
85
     /* This Content is provided under the terms and conditions of the Eclipse Public License Version 1.0 
86
("EPL"). A copy of the EPL is available at http://www.eclipse.org/org/documents/epl-v10.php 
87
For purposes of the EPL, "Program" will mean the Content. 
88
89
Copied from org.eclipse.jst.j2ee.ejb plugin. */ 
90
     
91
	Collection<String> imports = model.getImports();
92
	for (String anImport : imports) { 
93
94
    stringBuffer.append(TEXT_4);
95
    stringBuffer.append( anImport );
96
    stringBuffer.append(TEXT_5);
97
     
98
	}
99
100
    stringBuffer.append(TEXT_6);
101
     /* This Content is provided under the terms and conditions of the Eclipse Public License Version 1.0 
102
("EPL"). A copy of the EPL is available at http://www.eclipse.org/org/documents/epl-v10.php 
103
For purposes of the EPL, "Program" will mean the Content. 
104
105
Copied from org.eclipse.jst.j2ee.ejb plugin. */ 
106
    
107
	if (model.isPublic()) { 
108
109
    stringBuffer.append(TEXT_7);
110
     
111
	} 
112
113
	if (model.isAbstract()) { 
114
115
    stringBuffer.append(TEXT_8);
116
    
117
	}
118
119
	if (model.isFinal()) {
120
121
    stringBuffer.append(TEXT_9);
122
    
123
	}
124
125
    stringBuffer.append(TEXT_10);
126
    stringBuffer.append( model.getClassName() );
127
    
128
	String superClass = model.getSuperclassName();
129
 	if (superClass != null && superClass.length() > 0) {
130
131
    stringBuffer.append(TEXT_11);
132
    stringBuffer.append( superClass );
133
    
134
	}
135
136
	List<String> interfaces = model.getInterfaces(); 
137
 	if ( interfaces.size() > 0) { 
138
139
    stringBuffer.append(TEXT_12);
140
    
141
	}
142
	
143
 	for (int i = 0; i < interfaces.size(); i++) {
144
   		String INTERFACE = interfaces.get(i);
145
   		if (i > 0) {
146
147
    stringBuffer.append(TEXT_13);
148
    
149
		}
150
151
    stringBuffer.append( INTERFACE );
152
    
153
	}
154
155
    stringBuffer.append(TEXT_14);
156
     /* This Content is provided under the terms and conditions of the Eclipse Public License Version 1.0 
157
("EPL"). A copy of the EPL is available at http://www.eclipse.org/org/documents/epl-v10.php 
158
For purposes of the EPL, "Program" will mean the Content. 
159
160
Copied from org.eclipse.jst.j2ee.ejb plugin. */ 
161
     
162
	if (!model.hasEmptySuperclassConstructor()) { 
163
164
    stringBuffer.append(TEXT_15);
165
    stringBuffer.append( model.getClassName() );
166
    stringBuffer.append(TEXT_16);
167
     
168
	} 
169
170
	if (model.shouldGenSuperclassConstructors()) {
171
		List<Constructor> constructors = model.getConstructors();
172
		for (Constructor constructor : constructors) {
173
			if (constructor.isPublic() || constructor.isProtected()) { 
174
175
    stringBuffer.append(TEXT_17);
176
    stringBuffer.append( model.getSuperclassName() );
177
    stringBuffer.append(TEXT_18);
178
    stringBuffer.append( model.getSuperclassName() );
179
    stringBuffer.append(TEXT_19);
180
    stringBuffer.append( constructor.getParamsForJavadoc() );
181
    stringBuffer.append(TEXT_20);
182
    stringBuffer.append( model.getClassName() );
183
    stringBuffer.append(TEXT_21);
184
    stringBuffer.append( constructor.getParamsForDeclaration() );
185
    stringBuffer.append(TEXT_22);
186
    stringBuffer.append( constructor.getParamsForCall() );
187
    stringBuffer.append(TEXT_23);
188
    
189
			} 
190
		} 
191
	} 
192
193
     /* This Content is provided under the terms and conditions of the Eclipse Public License Version 1.0 
194
("EPL"). A copy of the EPL is available at http://www.eclipse.org/org/documents/epl-v10.php 
195
For purposes of the EPL, "Program" will mean the Content. 
196
197
Copied from org.eclipse.jst.j2ee.ejb plugin. */ 
198
    
199
	if (model.shouldImplementAbstractMethods()) {
200
		for (Method method : model.getUnimplementedMethods()) { 
201
202
    stringBuffer.append(TEXT_24);
203
    stringBuffer.append( method.getContainingJavaClass() );
204
    stringBuffer.append(TEXT_25);
205
    stringBuffer.append( method.getName() );
206
    stringBuffer.append(TEXT_26);
207
    stringBuffer.append( method.getParamsForJavadoc() );
208
    stringBuffer.append(TEXT_27);
209
    stringBuffer.append( method.getReturnType() );
210
    stringBuffer.append(TEXT_28);
211
    stringBuffer.append( method.getName() );
212
    stringBuffer.append(TEXT_29);
213
    stringBuffer.append( method.getParamsForDeclaration() );
214
    stringBuffer.append(TEXT_30);
215
     
216
			String defaultReturnValue = method.getDefaultReturnValue();
217
			if (defaultReturnValue != null) { 
218
219
    stringBuffer.append(TEXT_31);
220
    stringBuffer.append( defaultReturnValue );
221
    stringBuffer.append(TEXT_32);
222
    
223
			} 
224
225
    stringBuffer.append(TEXT_33);
226
     
227
		}
228
	} 
229
230
    stringBuffer.append(TEXT_34);
231
    
232
		String schedule = model.getProperty(AddEjbTimerDataModelProvider.SCHEDULE).trim();
233
	
234
    stringBuffer.append(TEXT_35);
235
    stringBuffer.append( schedule );
236
    stringBuffer.append(TEXT_36);
237
    return stringBuffer.toString();
238
  }
239
}
(-)ejbcreation/org/eclipse/jst/j2ee/internal/ejb/project/operations/EJBCreationResourceHandler.java (-1 / +5 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Oracle - EJB Timer
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jst.j2ee.internal.ejb.project.operations;
12
package org.eclipse.jst.j2ee.internal.ejb.project.operations;
12
13
Lines 167-173 Link Here
167
	public static String ERR_SINGLETON_NOT_ALLOWED;
168
	public static String ERR_SINGLETON_NOT_ALLOWED;
168
	public static String ERR_NO_INTERFACE_NOT_ALLOWED;
169
	public static String ERR_NO_INTERFACE_NOT_ALLOWED;
169
170
170
171
	//EJB Timer specific
172
    public static String timerScheduleDefault;
173
    public static String errorTimerScheduleMissing;
174
      
171
	static {
175
	static {
172
		NLS.initializeMessages(BUNDLE_NAME, EJBCreationResourceHandler.class);
176
		NLS.initializeMessages(BUNDLE_NAME, EJBCreationResourceHandler.class);
173
	}
177
	}
(-)property_files/ejbcreation.properties (+3 lines)
Lines 151-153 Link Here
151
WRN_NO_CLIENT_VIEW=No client view configured. Clients will not be able to access this bean.
151
WRN_NO_CLIENT_VIEW=No client view configured. Clients will not be able to access this bean.
152
ERR_SINGLETON_NOT_ALLOWED=The 'Singleton' state type is allowed only for EJB projects with version 3.1 or later.
152
ERR_SINGLETON_NOT_ALLOWED=The 'Singleton' state type is allowed only for EJB projects with version 3.1 or later.
153
ERR_NO_INTERFACE_NOT_ALLOWED=The no-interface client view is allowed only for EJB projects with version 3.1 or later. 
153
ERR_NO_INTERFACE_NOT_ALLOWED=The no-interface client view is allowed only for EJB projects with version 3.1 or later. 
154
155
timerScheduleDefault= second="*/10", minute="*", hour="8-23", dayOfWeek="Mon-Fri",\n      dayOfMonth="*", month="*", year="*", info="MyTimer"
156
errorTimerScheduleMissing=The schedule cannot be empty.
(-)templates/ejbtimer.javajet (+22 lines)
Added Link Here
1
<%@ jet package="org.eclipse.jst.j2ee.ejb.internal.operations" 
2
	imports="java.util.* org.eclipse.jst.j2ee.internal.common.operations.*" 
3
	class="EjbTimerTemplate" 
4
	skeleton="generator.skeleton"
5
%>
6
<% AddEjbTimerTemplateModel model = (AddEjbTimerTemplateModel) argument; %>
7
<%@ include file="_flags.template" %>
8
<%@ include file="_package.template" %>
9
<%@ include file="_imports.template" %>
10
@Stateless
11
<%@ include file="_class.template" %>
12
<%@ include file="_constructors.template" %>
13
<%@ include file="_methods.template" %>
14
	<%
15
		String schedule = model.getProperty(AddEjbTimerDataModelProvider.SCHEDULE).trim();
16
	%>
17
	@SuppressWarnings("unused")
18
	@Schedule(<%= schedule %>)
19
    private void scheduledTimeout(final Timer t) {
20
        System.out.println("@Schedule called at: " + new java.util.Date());
21
    }
22
}

Return to bug 299086