You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

WelcomePlugin.java 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright 2012 Decebal Suiu
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with
  5. * the License. You may obtain a copy of the License in the LICENSE file, or at:
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  10. * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
  11. * specific language governing permissions and limitations under the License.
  12. */
  13. package ro.fortsoft.pf4j.demo.welcome;
  14. import org.apache.commons.lang.StringUtils;
  15. import ro.fortsoft.pf4j.Extension;
  16. import ro.fortsoft.pf4j.Plugin;
  17. import ro.fortsoft.pf4j.PluginWrapper;
  18. import ro.fortsoft.pf4j.RuntimeMode;
  19. import ro.fortsoft.pf4j.demo.api.Greeting;
  20. /**
  21. * @author Decebal Suiu
  22. */
  23. public class WelcomePlugin extends Plugin {
  24. public WelcomePlugin(PluginWrapper wrapper) {
  25. super(wrapper);
  26. }
  27. @Override
  28. public void start() {
  29. System.out.println("WelcomePlugin.start()");
  30. // for testing the development mode
  31. if (RuntimeMode.DEVELOPMENT.equals(wrapper.getRuntimeMode())) {
  32. System.out.println(StringUtils.upperCase("WelcomePlugin"));
  33. }
  34. }
  35. @Override
  36. public void stop() {
  37. System.out.println("WelcomePlugin.stop()");
  38. }
  39. @Extension
  40. public static class WelcomeGreeting implements Greeting {
  41. @Override
  42. public String getGreeting() {
  43. return "Welcome";
  44. }
  45. }
  46. }